Chandu yadav has Published 1091 Articles

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

439 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

Move the first row to the end of the JTable in Java Swing

Chandu yadav

Chandu yadav

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

647 Views

To move the first row to the end of the table in Java, use the moveRow() method. It has three parameters. The first two parameters allows you to set the starting and ending row index to be moved. The last parameter sets the destination of the rows to be moved.As ... Read More

Python program to Count words in a given string?

Chandu yadav

Chandu yadav

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

3K+ Views

Lets suppose we have a ‘string’ and the ‘word’ and we need to find the count of occurence of this word in our string using python. This is what we are going to do in this section, count the number of word in a given string and print it.Count the ... Read More

Get the last days of all the months in MySQL?

Chandu yadav

Chandu yadav

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

127 Views

To get the last days of all the months, use the LAST_DAY() function from MySQL −SELECT LAST_DAY(yourColumnName) from yourTableName;Let us first create a table −mysql> create table DemoTable    (    ShippingDate date    ); Query OK, 0 rows affected (0.69 sec)Insert some records in the table using insert command ... Read More

Can we combine GridLayout and BorderLayout in Java?

Chandu yadav

Chandu yadav

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

652 Views

Yes, we can do that with Java Swings as shown below. Here, we have a panel set with GridLayout and another panel with BorderLayout −JPanel panelGrid = new JPanel(new GridLayout(10, 5, 10, 10)); panelGrid.add(new JCheckBox("Demo CheckBox1")); panelGrid.add(new JCheckBox("Demo CheckBox2")); panelGrid.add(btnAPanel); panelGrid.add(btnBPanel); panelGrid.add(btnCPanel); panelGrid.add(btnDPanel); JPanel panelBrdLayout = new JPanel(new BorderLayout()); panelBrdLayout.add(panelGrid, ... Read More

Program to get JTextArea font information

Chandu yadav

Chandu yadav

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

119 Views

Let’s say the following is our JTextArea −JTextArea textArea = new JTextArea("This is demo text.");Now, get the font using the Font class getFont() method as shown below −Font font = textArea.getFont(); System.out.println("Font = "+font);The following is an example to get JTextArea font information in Java −Examplepackage my; import java.awt.Font; import ... Read More

Permutation and Combination in Python?

Chandu yadav

Chandu yadav

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

1K+ Views

In this section, we are going to learn how to find permutation and combination of a given sequence using python programming language.One of the key advantage of python over other programming language is that it comes with huge set of libraries with it.We are going to use python inbuilt package ... Read More

How to create DefaultTableModel which is an implementation of TableModel

Chandu yadav

Chandu yadav

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

9K+ Views

Let us create DefaultTableModel −DefaultTableModel tableModel = new DefaultTableModel();Now, set the model to JTable −JTable table = new JTable(tableModel);Add a column −tableModel.addColumn("Languages");Now, we will add rows to our table −tableModel.insertRow(0, new Object[] { "CSS" }); tableModel.insertRow(0, new Object[] { "HTML5" });The following is an example to create DefaultTableModel −Examplepackage my; ... Read More

How to set border color for SoftBevelBorder in Java?

Chandu yadav

Chandu yadav

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

286 Views

To set the border color for SoftBevelBorder in Java, use the Color class and set the color while creating the border −SoftBevelBorder border = new SoftBevelBorder(    BevelBorder.RAISED, Color.ORANGE, Color.ORANGE.darker(), Color.BLUE, Color.magenta.brighter());We have set the following colors above as parameters −highlightOuterColor: color to use for the bevel outer highlight highlightInnerColor ... Read More

Write an equality in MongoDB without using $eq operator

Chandu yadav

Chandu yadav

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

114 Views

Let us first create a collection with documents -> db.operatorDemo.insertOne({"StudentSubject":["MongoDB", "MySQL", "Java"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cef94eaef71edecf6a1f6a2") } > db.operatorDemo.insertOne({"StudentSubject":["Java", "C", "C++"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cef94faef71edecf6a1f6a3") }Display all documents from a collection with the help of find() method -> db.operatorDemo.find().pretty();Output{   ... Read More

Advertisements