Chandu yadav has Published 1091 Articles

How can I position JButtons vertically one after another in Java Swing?

Chandu yadav

Chandu yadav

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

630 Views

Position buttons vertically one after another using the Box class. Use the createVerticalBox() method that displays components from top to bottom −JButton button1 = new JButton("One"); JButton button2 = new JButton("Two"); JButton button3 = new JButton("Three"); Box box = Box.createVerticalBox(); box.add(button1); box.add(button2); box.add(button3);The following is an example to position buttons ... Read More

Display dates after NOW() + 10 days from a MySQL table?

Chandu yadav

Chandu yadav

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

759 Views

You can use DATE_ADD() function with where clause for this. Let us first create a table −mysql> create table DemoTable    (    ShippingDate date    ); Query OK, 0 rows affected (0.54 sec)Note : The current date and time is as follows, we found using NOW() −mysql> select now(); ... Read More

How to create an invisible fixed height component between two components in Java?

Chandu yadav

Chandu yadav

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

186 Views

Use the createVerticalStrut() method to create an invisible fixed height component between two components. Let’s say we have some button and we are creating a fixed height between them −box.add(button4); box.add(Box.createVerticalStrut(50)); box.add(button5); box.add(Box.createVerticalStrut(30)); box.add(button6);The following is an example to create an invisible fixed height component between two components in Java ... Read More

MySQL query to alphabetize records and count the duplicates?

Chandu yadav

Chandu yadav

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

154 Views

For this, use both GROUP BY and ORDER BY clause. Let us first create a table −mysql> create table DemoTable    (    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    StudentGrade char(1)    ); Query OK, 0 rows affected (0.87 sec)Insert some records in the table using insert command ... Read More

HTML charset Attribute

Chandu yadav

Chandu yadav

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

717 Views

The charset attribute of the element is used to specify the character encoding for the HTML document. You can use the charset attribute on as well as element.Different charsets include ASCII, ANSI, ISO-8859-1, UTF-8, etc. ISO-8859-1 supports 256 different character codes. ASCII defined 128 different alphanumeric characters. ... Read More

Can we read from JOptionPane by requesting input from user in Java?

Chandu yadav

Chandu yadav

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

258 Views

Yes, we can read from JOptionPane. Here, we will get the result of the showInputDialog() in a String variable −String input = JOptionPane.showInputDialog("Enter the C++ lessons you covered till now?");After getting the result, we will convert it to integer with parseInt() and display it on Console −int res = Integer.parseInt(input); ... Read More

Sorted difference between two columns in MySQL?

Chandu yadav

Chandu yadav

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

515 Views

Use ORDER BY clause for this. Let us first create a table −mysql> create table DemoTable    (    Value1 int,    Value2 int    ); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(10, 40); Query OK, 1 ... Read More

HTML for Attribute

Chandu yadav

Chandu yadav

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

131 Views

The for attribute of the element sets the relationship between the result of the calculation and the elements used in the calculation.Following is the syntax:Above, id is the element id, which sets a separate list of one or more elements with a space. These elements specify the relationship between ... Read More

How to make JOptionPane to handle Yes, No and Closed buttons in Java?

Chandu yadav

Chandu yadav

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

2K+ Views

For this, create JOptionPane.QUESTION_MESSAGE and with the user action display individual messages, for example −int res = JOptionPane.showOptionDialog(new JFrame(), "Do you like Cricket?", "Hobbies", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new Object[] { "Yes", "No" }, JOptionPane.YES_OPTION); if (res == JOptionPane.YES_OPTION) {    System.out.println("Selected Yes!"); }Above, we have displayed a message on console ... Read More

Combining multiple rows into a comma delimited list in MySQL?

Chandu yadav

Chandu yadav

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

4K+ Views

To combine multiple rows into a comma delimited list, use the GROUP_CONCAT() method. Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Name varchar(30),    Marks int    ); Query OK, 0 rows affected (0.52 sec)Insert some records ... Read More

Advertisements