Ankith Reddy has Published 996 Articles

How to enable Scrolling Tabs in a JTabbedPane Container

Ankith Reddy

Ankith Reddy

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

359 Views

To enable scrolling tabs in a JTabbedPane container, use the setTabLayoutPolicy() method −tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);Above, we have set the constant to be SCROLL_TAB_LAYOUT, since we want the scroller to be visible when all the tabs won’t fit within a single run.The following is an example to enable scrolling tabs in a JTabbedPane ... Read More

Get rows with GROUP BY in MySQL?

Ankith Reddy

Ankith Reddy

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

242 Views

Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Subject varchar(20),    Price int    ); Query OK, 0 rows affected (0.64 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Subject, Price) values('MySQL', 456); ... Read More

How to create a compound border for a component in Java?

Ankith Reddy

Ankith Reddy

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

613 Views

Composed border consists of two or more borders i.e. border around a border. We can create it for a component in Java using the createCompoundBorder() method.Let’s say the following is our component −JLabel label; label = new JLabel("This has compound border (border around a border)!");Now, set the compound border −label.setBorder(BorderFactory.createCompoundBorder(BorderFactory ... Read More

Update all rows by prefixing a line to every text in MySQL?

Ankith Reddy

Ankith Reddy

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

321 Views

For this, use the CONCAT() function. Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Subject varchar(200)    ); Query OK, 0 rows affected (1.36 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Subject) ... Read More

How to delete '\' entry in MySQL?

Ankith Reddy

Ankith Reddy

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

122 Views

You can use delete command −delete from yourTableName where yourColumnName='\\';Let us first create a table −mysql> create table DemoTable    (    FolderName varchar(100)    ); Query OK, 0 rows affected (0.67 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values("????"); Query OK, 1 row ... Read More

Can we change the Cursor with Java Swing?

Ankith Reddy

Ankith Reddy

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

2K+ Views

Yes, we can change the default cursor representation in Java. Let us first create a button component −JButton button = new JButton("Button with two borders");Whenever user will keep the mouse cursor on the above button component, the cursor would change to hand cursor −Cursor cursor = button.getCursor(); button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));The following is ... Read More

Delete all rows except only a specific row in MySQL?

Ankith Reddy

Ankith Reddy

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

1K+ Views

To delete all rows except a single specific row, try the below syntax −delete from yourTableName where yourColumnName!=yourValue;Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Subject varchar(100)    ); Query OK, 0 rows affected (0.65 sec)Insert some ... Read More

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

Ankith Reddy

Ankith Reddy

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

258 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

2K+ 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

209 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

Advertisements