Arjun Thakur has Published 1109 Articles

MongoDB query to find data from an array inside an object?

Arjun Thakur

Arjun Thakur

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

448 Views

Let us first create a collection with documents −> db.findDataDemo.insertOne(    {       "_id": new ObjectId(),       "CustomerName":"John",       "CustomerDetails" : {          "CountryName" : [             "AUS"          ],       ... Read More

How to get the depth of root node in a JTree with Java?

Arjun Thakur

Arjun Thakur

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

268 Views

To get the depth of root node in a JTree in Java, use the getDepth() method. Let’s say our root node is “node”, therefore, we will get the depth of root node like this −node.getDepth();The following is an example to get the depth of root node −Examplepackage my; import javax.swing.JFrame; ... Read More

HTML
cite Attribute

Arjun Thakur

Arjun Thakur

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

212 Views

The cite attribute of the element is used to set the source of a quotation. Following is the syntax −Above, url is the source of the quotation. Let us now see an example to implement the cite attribute of the element −Example Live Demo Magento Magento as stated ... Read More

NZEC error in Python?

Arjun Thakur

Arjun Thakur

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

705 Views

NZEC is non-zero exit code.Exit codes are codes (number) return by running program to operating system upon either their successfully termination (Exit code 0) or failed termination due to error (Non zero exit code).As python or Java programming language supports exception handling, we can use exception handling using try-catch blocks ... Read More

How to create etched border for a component using BorderFactory class in Java?

Arjun Thakur

Arjun Thakur

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

198 Views

The etched border gives an ‘etched’ look. Let’s say the following is our component −JLabel label; label = new JLabel("This has etched border with an 'etched' look!");Let us create an etched border with BorderFactory class −label.setBorder(BorderFactory.createEtchedBorder());The following is an example to create etched border for a component using BorderFactory class ... Read More

Which MongoDB query finds same value multiple times in an array?

Arjun Thakur

Arjun Thakur

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

83 Views

You can use $where operator along with some script.Let us first create a collection with documents −> dbsameValueMultipleTimesDemoinsertOne(    {       "ListOfPrice":[          {"Price": 110},          {"Price":130},          {"Price": 145}       ]    } ); {   ... Read More

Display multiple components in an Internal Frame in Java

Arjun Thakur

Arjun Thakur

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

315 Views

At first, set an Internal Frame in the JDesktopPane −JDesktopPane desktopPane = new JDesktopPane(); JInternalFrame intFrame = new JInternalFrame("Our Frame", true, true, true, true); desktopPane.add(intFrame);Now, set the bounds of the Internal Frame −intFrame.setBounds(50, 90, 200, 250);Create two components −JLabel label = new JLabel(intFrame.getTitle(), JLabel.CENTER); JButton button = new JButton("Demo Button");Add ... Read More

Delete specific record from an array nested within another array in MongoDB?

Arjun Thakur

Arjun Thakur

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

131 Views

To delete specific record, use $pull operator. Let us first create a collection with documents −> dbdeletingSpecificRecordDemoinsertOne(    {       "StudentDetails": [          {             "StudentName": "John",             "StudentSubjectDetails": [           ... Read More

How to add a Tab in JTabbedPane with Java?

Arjun Thakur

Arjun Thakur

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

1K+ Views

Let us first create a JTabbedPane −JTabbedPane tabbedPane = new JTabbedPane();Create some panels −JPanel panel1, panel2, panel3, panel4, panel5; panel1 = new JPanel(); panel2 = new JPanel(); panel3 = new JPanel(); panel4 = new JPanel(); panel5 = new JPanel();Now, add tabs using the addTab() method and set the panels as ... Read More

How to set horizontal gap between elements in a GridLayout with Java?

Arjun Thakur

Arjun Thakur

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

4K+ Views

Use the setHgap() method to set the horizontal gap between elements in a GridLayout. Let’s say we have a GridLaypout −GridLayout layout = new GridLayout(2, 4);Set the horizontal gap −layout.setHgap(25);The following is an example −Examplepackage my; import java.awt.Color; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Font; import java.awt.GridLayout; import javax.swing.JButton; import javax.swing.JFrame; ... Read More

Advertisements