Nishtha Thakur has Published 498 Articles

Selecting database inside the JS in MongoDB?

Nishtha Thakur

Nishtha Thakur

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

128 Views

You can use getSiblingDB() from MongoDB for this using var keyword from JS −anyVariableName= db.getSiblingDB(‘yourDatabaseName’);Let us implement the above syntax in order to select database −> selectedDatabase = db.getSiblingDB('sample');This will produce the following output −SampleNow, insert some documents. Let’s say the collection is ‘selectDatabaseDemo’ −> db.selectDatabaseDemo.insertOne({"ClientName":"John Smith", "ClientAge":23}); {   ... Read More

How to create a Default Cell Editor that uses a JCheckBox in Java?

Nishtha Thakur

Nishtha Thakur

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

325 Views

Create a check box first and set valueJCheckBox checkBox = new JCheckBox("In-Stock");Set the JCheckBox for the editor so that the editor uses the check box −TreeCellEditor editor = new DefaultCellEditor(comboBox); tree.setEditable(true); tree.setCellEditor(editor);The following is an example to create a Default Cell Editor that uses a JCheckBox −Examplepackage my; import javax.swing.DefaultCellEditor; ... Read More

How do I catch a Ctrl+C event in C++?

Nishtha Thakur

Nishtha Thakur

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

14K+ Views

The CTRL + C is used to send an interrupt to the current executing task. In this program, we will see how to catch the CTRL + C event using C++.The CTRL + C is one signal in C or C++. So we can catch by signal catching technique. For ... Read More

How to display vertical grid lines in a table with Java?

Nishtha Thakur

Nishtha Thakur

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

424 Views

To display vertical grid lines in a table, use the setShowVerticalLines() method. Let us first create a table −String[][] rec = {    { "1", "Steve", "AUS" },    { "2", "Virat", "IND" },    { "3", "Kane", "NZ" },    { "4", "David", "AUS" },    { "5", "Ben", ... Read More

How to perform $gt on a hash in a MongoDB document?

Nishtha Thakur

Nishtha Thakur

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

119 Views

The $gt is for greater than, wherein select those documents where the value of the field is greater than the specified value. Let us first create a collection with documents −> db.performQueryDemo.insertOne({"PlayerDetails":{"PlayerScore":1000, "PlayerLevel":2}, "PlayerName":"Chris"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd7eba41a844af18acdffa9") } > db.performQueryDemo.insertOne({"PlayerDetails":{"PlayerScore":0, "PlayerLevel":1}, "PlayerName":"Robert"}); {   ... Read More

How to get notified when a notification is notified?

Nishtha Thakur

Nishtha Thakur

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

78 Views

This example demonstrate about How to get notified when a notification is notifiedStep 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 ... Read More

Find the MongoDB document from sub array?

Nishtha Thakur

Nishtha Thakur

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

431 Views

You can use dot(.) notation to find the document from sub array. Let us first create a collection with documents −> db.findDocumentDemo.insertOne( ...    { ...       "EmployeeDetails" : ...       { ...          "EmployeeAppraisalTime": ... ...          [ ... ... Read More

How to add a title to JTable in Java Swing?

Nishtha Thakur

Nishtha Thakur

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

2K+ Views

To display a title to the JTable, you can set a title for the JPanel, which already consists of a JTable.Here, we are using createTitledBorder() for the JPanel to set the title for the panel border that would eventually work for table title.Let’s say the following is the JPanel −JPanel ... Read More

MongoDB regex to display records whose first five letters are uppercase?

Nishtha Thakur

Nishtha Thakur

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

958 Views

Let us first create a collection with documents −> db.upperCaseFiveLetterDemo.insertOne({"StudentFullName":"JOHN Smith"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd7edef1a844af18acdffb2") } > db.upperCaseFiveLetterDemo.insertOne({"StudentFullName":"SAM Williams"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd7ee011a844af18acdffb3") } > db.upperCaseFiveLetterDemo.insertOne({"StudentFullName":"CAROL Taylor"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd7ee101a844af18acdffb4") } > db.upperCaseFiveLetterDemo.insertOne({"StudentFullName":"Bob Taylor"}); ... Read More

Java Program to set the content of the JLabel to be right-justified and bottom-aligned

Nishtha Thakur

Nishtha Thakur

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

120 Views

To set the text of the label component to be right-justified and bottom-aligned, you need to set the alignment. Set the label to be on the right and bottom aligned −JLabel label = new JLabel("Total Runs", JLabel.RIGHT); label.setVerticalAlignment(JLabel.BOTTOM);Here, we have set the size of the label as well as the ... Read More

Advertisements