Ankith Reddy has Published 1070 Articles

How to deselect a range of rows from a table in Java?

Ankith Reddy

Ankith Reddy

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

182 Views

Let’s say, we have selected a range of rows using addRowSelectionInterval() as shown in the demo screenshot −Now, we will deselect the above shown selected rows using removeRowSelectionInterval(). The range is to be set here for interval i.e rows 3 to 6 (index 2 to 5) will get deselected −table.removeRowSelectionInterval(2, ... Read More

Set all values in a MySQL field to 0?

Ankith Reddy

Ankith Reddy

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

1K+ Views

To set all the values in a field to 0, use the update command −update yourTableName set yourColumnName=0;Let us first create a table −mysql> create table DemoTable    (    Number int    ); Query OK, 0 rows affected (0.64 sec)Insert some records in the table using insert command −mysql> ... Read More

How to add separator in a ToolBar with Java?

Ankith Reddy

Ankith Reddy

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

125 Views

To add a separator, use the addSeparator() method. Let us first create a toolbar −JToolBar toolbar = new JToolBar();Now, we will create some components and set a separator to separate them as shown below −toolbar.add(new JTextArea(" Add name here")); toolbar.add(new JButton("Submit Name")); toolbar.addSeparator(); toolbar.add(new JTextArea(" Add age here")); toolbar.add(new JButton("Submit ... Read More

Can we create nested TitiledBorder in Java?

Ankith Reddy

Ankith Reddy

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

82 Views

Yes, we can create nested TitledBorder. Let us first create a component for which we will set the border −JLabel label = new JLabel();Now, we will create the 1st border −TitledBorder border = BorderFactory.createTitledBorder("Top Border"); border.setTitlePosition(TitledBorder.TOP);Following is how we will creater border 2. We have set the 1st border here ... Read More

HTML Tag

Ankith Reddy

Ankith Reddy

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

50 Views

The element in HTML is used to set keyboard input. Since the element deprecated now, therefore use instead.Note: The tag is not supported in HTML.Let us now see an example to implement the tag in HTML−Example Live Demo Shortcut Keys Use the following shortcut keys: ... Read More

How to set TitiledBorder Direction in Java?

Ankith Reddy

Ankith Reddy

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

97 Views

To set TitleBorder direction, you need to use the constants and set it for border. For example, for direction center −TitledBorder border = BorderFactory.createTitledBorder("Border"); border.setTitlePosition(TitledBorder.CENTER);Above, we have set the setTitlePosition() for the direction.The following is an example to set TitledBorder direction in Java −Examplepackage my; import java.awt.BorderLayout; import java.awt.Container; import ... Read More

OpenCV Python Program to blur an image?

Ankith Reddy

Ankith Reddy

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

465 Views

OpenCV is one of the best python package for image processing. Also like signals carry noise attached to it, images too contain different types of noise mainly from the source itself (Camera sensor). Python OpenCV package provides ways for image smoothing also called blurring. This is what we are going ... Read More

Projection result as an array of selected items in MongoDB?

Ankith Reddy

Ankith Reddy

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

104 Views

Use the distinct() for this, since it finds the distinct values for a specified field across a single collection or view and returns the results in an array.Let us first create a collection with documents −> db.projectionListDemo.insertOne({"_id":"1", "Subject":["MongoDB", "MySQL", "Java"]}); { "acknowledged" : true, "insertedId" : "1" } > db.projectionListDemo.insertOne({"_id":"2", ... Read More

How to find a node in a JTree Component with Java?

Ankith Reddy

Ankith Reddy

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

588 Views

To find a node in a JTree component, use the getNextMatch() method. Here, wer are trying to find a node that begins with character “A”. The search begins from the node set below with begnRow variable −int begnRow = 0; String prefix = "A"; TreePath treePath = tree.getNextMatch(prefix, begnRow, Position.Bias.Forward);We ... Read More

Check if hidden files are displayed in the FileChooser or not in Java

Ankith Reddy

Ankith Reddy

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

61 Views

The result FALSE for is FileHidingEnabled() means the hidden files are displayed in the FileChooser. The following will display FALSE since file isn’t hidden −JFileChooser file = new JFileChooser(); file.setMultiSelectionEnabled(false); file.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); file.setFileHidingEnabled(false); boolean res = file.isFileHidingEnabled();Above, at first, we have displayed the file by setting hidden to be FALSE −file.setFileHidingEnabled(false);The following ... Read More

Advertisements