Chandu yadav has Published 1091 Articles

MongoDB regular expression to match a specific record?

Chandu yadav

Chandu yadav

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

137 Views

Let us first create a collection with documents −> dbworkingOfRegularExpressionDemoinsertOne({ "StudentDetails" : { "StudentName" : "John" }, "StudentAge":21 }); {    "acknowledged" : true,    "insertedId" : ObjectId("5cf227acb64a577be5a2bc07") } > dbworkingOfRegularExpressionDemoinsertOne({ "StudentDetails" : { "StudentName" : "JOHN" }, "StudentAge":19 }); {    "acknowledged" : true,    "insertedId" : ObjectId("5cf227b8b64a577be5a2bc08") } ... Read More

How to specify tab location to make it visible in the bottom with Java?

Chandu yadav

Chandu yadav

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

153 Views

Use the setTabPlacement() method to set the tab location. To make it visible in the bottom, use the BOTTOM constant −JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.setTabPlacement(JTabbedPane.BOTTOM);The following is an example to specify tab location to make it visible in the bottom −package my; import javax.swing.*; import java.awt.*; import java.awt.event.KeyEvent; public ... Read More

How to display the vertical and horizontal scrollbars always even if it is not required

Chandu yadav

Chandu yadav

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

107 Views

Use the following constants for the JScrollBar to display the vertical and horizontal scrollbars always even if it is not required −scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);The following is an example to display the vertical and horizontal scrollbars always even if it is not required −Examplepackage my; import java.awt.BorderLayout; import java.awt.Dimension; import javax.swing.Box; import ... Read More

Find documents that contains specific field in MongoDB?

Chandu yadav

Chandu yadav

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

180 Views

For this, use the $exists operator. Let us first create a collection with documents −>dbfindDocumentContainsSpecificFieldDemoinsertOne({"ProductPrices":{"Product1":10, "Pr oduct2":50}}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cf2385bb64a577be5a2bc14") } >dbfindDocumentContainsSpecificFieldDemoinsertOne({"ProductPrices":{"Product3":150, "P roduct7":100, "Product5":250}}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cf2387eb64a577be5a2bc15") }Following is the query to display all documents from a ... Read More

How to get this node’s first child in a JTree with Java?

Chandu yadav

Chandu yadav

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

397 Views

Let’s say we want the first child node of a node, then use the getFirstChild() method −node2.getFirstChild()Display the node’s first child on Console −System.out.println("The first child of node 2 = "+node2.getFirstChild());The following is an example to get this node’s first child in a JTree −package my; import javax.swing.JFrame; import javax.swing.JTree; ... Read More

How to determine whether the JSlider is currently snapping to tick marks in Java?

Chandu yadav

Chandu yadav

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

188 Views

At first, we will create a slider and set it to snap to tick marks:JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 100, 40); slider.setMinorTickSpacing(10); slider.setMajorTickSpacing(20); slider.setPaintTicks(true); slider.setPaintLabels(true); slider.setSnapToTicks(true);After that, we will check whether the slider is currently snapping to tick marks. The result would be displayed in the TRUE/FALSE booleanslider.getSnapToTicks()Display the ... Read More

HTML type Attribute

Chandu yadav

Chandu yadav

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

99 Views

The type attribute of the element sets the MIME (Multipurpose Internet Mail Extensions) type of the target url. Following is the syntax −Above, type_of_media is the standard media type of the linked document, for example, image/bmp, image/tiff, image/tff, etc.Let us now see an example to implement the type attribute ... Read More

How to change the background color of ListView items on Android?

Chandu yadav

Chandu yadav

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

2K+ Views

This example demonstrate about How to change the background color of ListView items on Android.Step 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.   ... Read More

How to add new contacts in Android App?

Chandu yadav

Chandu yadav

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

1K+ Views

This example demonstrate about How to add new contacts in Android App.Step 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         ... Read More

How to create circular ProgressBar in Android?

Chandu yadav

Chandu yadav

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

3K+ Views

This example demonstrate about How to create circular ProgressBar in Android.Step 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/drawable/circular_progress_bar.xml.         ... Read More

Advertisements