Anvi Jain has Published 629 Articles

How to create Vertical progress bar occupying the entire frame in Java

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

160 Views

For this, create a vertical progress bar −JProgressBar progressBar = new JProgressBar(JProgressBar.VERTICAL); progressBar.setEnabled(true);Also, set the bounds −progressBar.setBounds(70, 50, 120, 30);The following is an example to create vertical progress bar occupying the entire frame −Examplepackage my; import java.awt.BorderLayout; import java.awt.Color; import javax.swing.JFrame; import javax.swing.JProgressBar; public class SwingDemo {    public static ... Read More

Merge two array fields in MongoDB?

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

578 Views

To merge, use $setUnion operator. Let us first create a collection with documents −> db.mergeTwoArrayFieldDemo.insertOne({"NaturalNumbers":[1, 2, 3, 8, 10, 20, 30], "WholeNumbers":[0, 1, 2, 63, 78, 20, 45]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd68e4057806ebf1256f11d") }Following is the query to display all documents from a collection with the ... Read More

Start an Activity from a Notification in Android?

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

866 Views

This example demonstrate about Start an Activity from a Notification in AndroidStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     Step 3 ... Read More

Java Program to set an icon for JOptionPane

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

1K+ Views

Let us first set an image with Image Icon class −ImageIcon icon = new ImageIcon(new URL("http://www.tutorialspoint.com/images/css.png"));Now, set it to a component −JLabel label = new JLabel(icon);Add the component to the panel −JPanel panel = new JPanel(new GridBagLayout()); panel.add(label);The following is an example to set an icon for JOptionPane −Examplepackage my; ... Read More

Difference between files written in binary and text mode in C++

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

518 Views

Text modeBinary modeIn text mode various character translations are performed i.e;“\r+\f” is converted into “”In binary mode, such translations are not performed.To write in the files:ofstream ofs (“file.txt”);Orofstream ofs;ofs.open(“file.txt”);to write in the files: ofstream ofs(“file.txt”, ios::binary);orofstream ofs;ofs.open(“file.txt”, ios::binary);To add text at the end of the file:Ofstream ofs(“file.txt”, ios::app);orofstream ofs;ofs.open(“file.txt”, ios::app);To add text ... Read More

How to pull all elements from an array in MongoDB without any condition?

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

281 Views

You can use $set operator for this. Let us first create a collection with documents −> db.pullAllElementDemo.insertOne( ...    { ...       "StudentId":101, ...       "StudentDetails" : [ ...          { ... ...             "StudentName": "Carol", ...   ... Read More

Add multiple number input fields with JOptionPane and display the sum in Console with Java

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

2K+ Views

At first, set multiple number input fields −JTextField text1 = new JTextField(10); JTextField text2 = new JTextField(10); JTextField text3 = new JTextField(10); JTextField text4 = new JTextField(10); JTextField text5 = new JTextField(10); JTextField text6 = new JTextField(10); JTextField text7 = new JTextField(10); JTextField text8 = new JTextField(10); panel.add(text1); panel.add(text2); panel.add(text3); ... Read More

Static Data Member Initialization in C++

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

3K+ Views

Here we will see how to initialize the static member variables initialization in C++. We can put static members (Functions or Variables) in C++ classes. For the static variables, we have to initialize them after defining the class.To initialize we have to use the class name then scope resolution operator, ... Read More

Get maximum and minimum value in MongoDB?

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

1K+ Views

Use $max and $min operator along with aggregate framework to get the maximum and minimum value. Let us first create a collection with documents −> db.maxAndMinDemo.insertOne({"Value":98}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd698a357806ebf1256f129") } > db.maxAndMinDemo.insertOne({"Value":97}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd698af57806ebf1256f12a") } > db.maxAndMinDemo.insertOne({"Value":69}); ... Read More

How to write my own header file in C?

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

1K+ Views

Steps to write my own header file in C −Type a code and save it as “sub.h”.Write a main program “subtraction.c” in which −include new header file.Write “sub.h” instead of All the functions in sub.h header are now ready for use.Directly call the function sub().Both “subtraction.c” and “sub.h” should be ... Read More

Advertisements