
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Ankith Reddy has Published 996 Articles

Ankith Reddy
3K+ Views
To create a Box Layout in Java Swing, use the BoxLayout class. Here, we have also set that the components should be laid our left to right or top to bottom −Box box = new Box(BoxLayout.X_AXIS); box.add(button1); box.add(button2); box.add(button3); box.add(button4); box.add(Box.createGlue()); box.add(button5); box.add(button6); box.add(button7); box.add(button8);Above, we have 8 buttons in ... Read More

Ankith Reddy
625 Views
Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Score int ); Query OK, 0 rows affected (0.89 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Score) values(67); Query OK, 1 row affected ... Read More

Ankith Reddy
501 Views
To set the location of component, use the GridBagConstraints. Here, we have two components −GridBagConstraints gbc = new GridBagConstraints(); JLabel label = new JLabel("Email-Id − "); JTextArea text = new JTextArea(); text.setText("Add id here...");Set the location with gridx and gridy −gbc.gridx = 0; gbc.gridy = 0; layout.setConstraints(label, gbc); panel.add(label);The following ... Read More

Ankith Reddy
269 Views
Yes, we can do that. Let us first create a table −mysql> create table DemoTable ( ID int, GameScore int ); Query OK, 0 rows affected (0.55 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(15, 848747); Query OK, 1 row ... Read More

Ankith Reddy
228 Views
To enable colum selection, use the setColumnSelectionAllowed() method and set it to TRUE −table.setCell setColumnSelectionAllowed(true);The following is an example to enable column selection in 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; public class SwingDemo { public static void ... Read More

Ankith Reddy
493 Views
Here, now() represents the current date. To check whether it falls between two specific dates, you need to use the BETWEEN. Let us first create a table −mysql> create table DemoTable ( FirstDate datetime, SecondDate datetime ); Query OK, 0 rows affected (0.60 sec)Insert some records ... Read More

Ankith Reddy
175 Views
Use keyword AS for this. Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Name varchar(20) ); Query OK, 0 rows affected (3.16 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Name) values('John'); ... Read More

Ankith Reddy
237 Views
For predefined selection, use the setSelectedIndex() method, wherein you need to set the index of the item you want to be visible first.Let’s say the following is our aComboBox with elements −Object[] sports = { "Football", "Cricket", "Squash", "Baseball", "Fencing", "Volleyball", "Basketball" }; JComboBox comboBox = new JComboBox(sports);Now, set the ... Read More

Ankith Reddy
543 Views
Let us first create a table with one of the column as ID −mysql> create table DemoTable ( ID int, StudentName varchar(10), CountryName varchar(20) ); Query OK, 0 rows affected (0.70 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(0, ... Read More

Ankith Reddy
1K+ Views
For this, use the aggregate function COUNT() along with GROUP BY. Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Value int ); Query OK, 0 rows affected (0.74 sec)Insert some records in the table using insert ... Read More