Arjun Thakur has Published 1025 Articles

Display multiple components in an Internal Frame in Java

Arjun Thakur

Arjun Thakur

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

438 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

190 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

How to limit the amount of characters returned from a field in a MongoDB query?

Arjun Thakur

Arjun Thakur

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

167 Views

For this, use MongoDB $substr. Let us first create a collection with documents −> dblimitTheNumberOfCharactersDemoinsertOne({"Title":"MongoDB is No SQL database"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cf23013b64a577be5a2bc0e") } > dblimitTheNumberOfCharactersDemoinsertOne({"Title":"MySQL is a relational database"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cf2302db64a577be5a2bc0f") } Following is the query ... Read More

How to check if two nodes are equal in a JTree with Java?

Arjun Thakur

Arjun Thakur

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

790 Views

To check if two nodes are equal, use the equals() method. Here, we are checking that node1 and node2 are equal or not.node1.equals(node2)The following is an example to check if two nodes are equal in a JTree −package my; import javax.swing.JFrame; import javax.swing.JTree; import javax.swing.tree.DefaultMutableTreeNode; public class SwingDemo {   ... Read More

How to enable the display of hidden files in a JFileChooser in Java?

Arjun Thakur

Arjun Thakur

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

361 Views

Set the following to FALSE to enable the display of hidden files −JFileChooser file = new JFileChooser(); file.setFileHidingEnabled(false);The following is an example to enable the display of hidden files in a JFileChooser −Examplepackage my; import javax.swing.JFileChooser; public class SwingDemo {    public static void main(String[] args) {       ... Read More

HTML currentTarget Event Property

Arjun Thakur

Arjun Thakur

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

144 Views

The currentTarget event property in HTML is used to get the element whose event listeners triggered the event.Following is the syntax −event.currentTargetLet us now see an example to implement the currentTarget event property −Example Live Demo Get the element Click on this line to generate an alert box displaying ... Read More

How to turn Android device screen on and off programmatically?

Arjun Thakur

Arjun Thakur

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

4K+ Views

This example demonstrate about How to turn Android device screen on and off programmatically.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 lock the Android device programmatically?

Arjun Thakur

Arjun Thakur

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

4K+ Views

This example demonstrate about How to lock the Android device programmatically.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

Advertisements