Chandu yadav has Published 1090 Articles

How to expand JTree row to display all the nodes and child nodes in Java

Chandu yadav

Chandu yadav

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

995 Views

To expand JTree row to display all the nodes and child nodes, use the expandRow() method in Java. At first, create a node −DefaultMutableTreeNode node = new DefaultMutableTreeNode("Project");Now, add nodes to the node created above −DefaultMutableTreeNode node1 = new DefaultMutableTreeNode("App"); DefaultMutableTreeNode node2 = new DefaultMutableTreeNode("Website"); DefaultMutableTreeNode node3 = new DefaultMutableTreeNode("WebApp"); ... Read More

How to set a MatteBorder from BorderFactory in Java?

Chandu yadav

Chandu yadav

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

211 Views

Set a MatteBorder from BorderFactory class −MatteBorder border = (MatteBorder)BorderFactory.createMatteBorder(2, -1, 5, 10, icon);Now, set the above created MatteBorder to a component −JButton button = new JButton("Matte Border"); button.setBorder(border);The following is an example to set a MatteBorder from BorderFactory class −Examplepackage my; import java.awt.BorderLayout; import java.awt.Container; import javax.swing.BorderFactory; import javax.swing.ImageIcon; ... Read More

How to set the grid color of a table in Java?

Chandu yadav

Chandu yadav

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

1K+ Views

To set the grid color of a table, use the setGridColor() method.table.setGridColor(Color.yellow);Above, we have used the Color class to set the color.The following is an example to set the grid color of a table −Examplepackage my; import java.awt.Color; import javax.swing.BorderFactory; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.border.TitledBorder; ... Read More

Retrieve from MySQL only if it contains two hyphen symbols?

Chandu yadav

Chandu yadav

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

575 Views

For this, use the LIKE operator. Let us first create a table:mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Password varchar(100)    ); Query OK, 0 rows affected (1.27 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Password) values('John@--123'); ... Read More

Can we display a JTabPane with TextArea in one of the tabs with Java

Chandu yadav

Chandu yadav

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

272 Views

Yes, we can display a JTabPane with TextArea in one of the tabs. For that, let us first create a JTabbedPane component −JTabbedPane tabbedPane = new JTabbedPane();Now, create a text area you want to set under one of the tabs −JTextArea text = new JTextArea(100, 100);Now, set panels for the ... Read More

When to use yield instead of return in Python?

Chandu yadav

Chandu yadav

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

1K+ Views

In short, whenever control reach the return statement in your program, the execution of the program is terminated and the remaining statements will not executed.However, in case of yield, whenever control reach the yield statement in your program, the execution of your program is paused and later we can continue ... Read More

HTML
    start Attribute

Chandu yadav

Chandu yadav

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

117 Views

The start attribute of the element is used to set the start value of the first list item.. Following is the syntax−Above, num is the number set for the start value of the first list item. Let us now see an example to implement the start attribute of the ... Read More

How to create Titled Border for a component in Java?

Chandu yadav

Chandu yadav

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

2K+ Views

To create a titled border for a component in Java, use the createTitledBorder() method. Let’s say we have a panel and we need to set a titled border to it. Here’s our panel −JPanel panel = new JPanel();Now, set the border and set the text for the tites border −panel.setBorder(BorderFactory.createTitledBorder( ... Read More

MySQL query to convert a string like “1h 15 min” into 75 minutes?

Chandu yadav

Chandu yadav

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

152 Views

You can use str_to_date() for this conversion. Let us first create a table −mysql> create table DemoTable    (    stringDate varchar(100)    ); Query OK, 0 rows affected (0.86 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('1h 15 min'); Query OK, 1 row ... Read More

Can we prevent the collapse of nodes and child nodes in a JTree with Java?

Chandu yadav

Chandu yadav

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

452 Views

Yes, we can prevent the collapse of nodes and child nodes in a JTree using setExpandedState() method. This method sets the expanded state of this JTree.If state istrue, all parents of path and path are marked asexpanded.The following is an example that prevents the collapse of nodes and child nodes ... Read More

Advertisements