Anvi Jain has Published 629 Articles

Program to combine BorderLayout, GridLayout and FlowLayout in Java Swing?

Anvi Jain

Anvi Jain

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

1K+ Views

Here, we have set panels with BorderLayout, GridLayout and FlowLayout. Within the panels, we have created components such as Button, ComboBox, etc. The following is an example to combine layouts in Java −Examplepackage my; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.GridLayout; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JFrame; import javax.swing.JPanel; ... Read More

Modulus of two float or double numbers using C

Anvi Jain

Anvi Jain

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

6K+ Views

Here we will see how to get the modulus of two floating or double type data in C. The modulus is basically finding the remainder. For this, we can use the remainder() function in C. The remainder() function is used to compute the floating point remainder of numerator/denominator.So the remainder(x, ... Read More

C++ Program to print the diamond shape

Anvi Jain

Anvi Jain

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

379 Views

This is a C++ Program to print the diamond shape.AlgorithmBegin    Take the no of rows n means the dimension of the diamond shape as input.    Declare the variables i, j and initialize space=1.    Initialize space = n-1.    Run for loop till n.       Run ... Read More

Check if value exists for a field in a MongoDB document?

Anvi Jain

Anvi Jain

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

1K+ Views

To check if value exists for a field in a MongoDB document, you can use find() along with $exists operator. Let us first create a collection with documents −> db.checkIfValueDemo.insertOne({"PlayerName":"John Smith", "PlayerScores":[5000, 98595858, 554343]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cc6f507af8e7a4ca6b2ad98") } > db.checkIfValueDemo.insertOne({"PlayerName":"John Doe", "PlayerScores":[]}); {   ... Read More

How to set the alignment of the JLabel content along the X axis in Java?

Anvi Jain

Anvi Jain

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

580 Views

To set the alignment of the label content along the X axis, use the setHorizontalAlignment() method. Let us first set a label component. We have set the label background color as well so that we can check the alignment of the label’s content properly −JLabel label = new JLabel("Team "); ... Read More

C++ Program to Check Whether Topological Sorting can be Performed in a Graph

Anvi Jain

Anvi Jain

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

478 Views

In a Directed Acyclic Graph, we can sort vertices in linear order using topological sort.Topological sort is only work on Directed Acyclic Graph. In a Directed Acyclic Graph (DAG), there can be more than one topological sort.In the following C++ program, we shall perform topological sort to check existence of ... Read More

Regex to ignore a specific character in MongoDB?

Anvi Jain

Anvi Jain

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

803 Views

You can use regular expression along with $not operator to ignore a specific character and display rest of them. Let us first create a collection with documents −> db.regexDemo.insertOne({"CustomerId":"Customer#1234", "CustomerName":"Chris"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cc7428f8f9e6ff3eb0ce436") } > db.regexDemo.insertOne({"CustomerId":"Customer5678", "CustomerName":"Robert"}); {    "acknowledged" : true,    "insertedId" ... Read More

How to add a field with static value to MongoDB find query?

Anvi Jain

Anvi Jain

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

466 Views

You can use $literal operator along with aggregate framework. Let us first create a collection with documents −> db.fieldWithStaticValue.insertOne({"Name":"Larry", "Age":24}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd6554c7924bb85b3f48948") } > db.fieldWithStaticValue.insertOne({"Name":"Chris", "Age":23}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd655567924bb85b3f48949") } > db.fieldWithStaticValue.insertOne({"Name":"David", "Age":26}); {    "acknowledged" : ... Read More

Can I get the node at a specified index in a JTree with Java?

Anvi Jain

Anvi Jain

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

312 Views

To get the node at a specified index in a JTree, use the getChildAt() method. Here, we are finding the node at index 3 i.e. 4th node −node.getChildAt(3)The following is an example to get the node at a specified index in a JTree −Examplepackage my; import javax.swing.JFrame; import javax.swing.JTree; import ... Read More

C++ Program to Show the Duality Transformation of Line and Point

Anvi Jain

Anvi Jain

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

153 Views

This is a C++ Program to show the Duality Transformation of Line and Point. So it can have two cases −Case-1: A point (a, b) is transformed to the line (y = ax − b).Case-2: A line D(y = cx + d) is transformed to the point D’(c, −d).Functions and ... Read More

Advertisements