George John has Published 1167 Articles

Customize the JOptionPane layout with updated color and image in Java

George John

George John

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

1K+ Views

Customize the layout by changing the look and feel of the panel in which you added the component −ImageIcon icon = new ImageIcon(new URL("http −//www.tutorialspoint.com/images/C-PLUS.png")); JLabel label = new JLabel(icon); JPanel panel = new JPanel(new GridBagLayout()); panel.add(label); panel.setOpaque(true); panel.setBackground(Color.ORANGE);Above, we have added an image and even updated the background color ... Read More

HTML data Attribute
George John

George John

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

67 Views

Tha data attribute of the element sets the URL of the resource, which can be audio, video, pdf, flash, etc. used by the object.Following is the syntax:The url is the URL of the resource used by the object.Let us now see an example to implement the data attribute of ... Read More

Get MAX() on column in two MySQL tables?

George John

George John

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

404 Views

Use GREATEST() to find the maximum. Let us first create a table −mysql> create table DemoTable1    (    Number int    ); Query OK, 0 rows affected (0.52 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1 values(80); Query OK, 1 row affected (0.26 sec) ... Read More

Java Program to set JComboBox in JOptionPane

George John

George John

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

1K+ Views

Let us first crate a ComboBox and add items to it −Object[] sports = { "Football", "Cricket", "Squash", "Baseball", "Fencing", "Volleyball", "Basketball" }; JComboBox comboBox = new JComboBox(sports);Now, add the combo box to the JOptionPane −JOptionPane.showMessageDialog(null, comboBox, "Fav Sports", JOptionPane.QUESTION_MESSAGE);The following is an example to set JComboBox in JOptionPane −Examplepackage ... Read More

How to order by a custom rule like order like 4,2,1,3 in MySQL?

George John

George John

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

203 Views

To order with a custom rule, use the ORDER BY FIELD(). Let us first create a table −mysql> create table DemoTable    (    Number int    ); Query OK, 0 rows affected (0.55 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(1); Query OK, ... Read More

Mathematical Functions in Python?

George John

George John

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

2K+ Views

From doing simple to complex mathematical operations(like trigonometric, logarithmic operations etc) in python we may need to use the math() module.The python math module is used to access mathematical functions. All methods of math() function are used for integer or real type objects but not for complex numbers.To use this ... Read More

MySQL query to get current datetime and only current date

George John

George John

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

293 Views

The query SELECT NOW() gives the current date as well as current time. If you want only current date, use only CURDATE(). Following is the syntax for datetime −SELECT NOW();The syntax for only date.SELECT CURDATE();Let us now implement the above syntax −Case 1 : If you want both current date ... Read More

How to create input Pop-Ups (Dialog) and get input from user in Java?

George John

George John

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

629 Views

Use the JOptionPane.showInputDialog() to get input from user in a dialog box like “Which sports you play the most”, “What is your name”, etc. The following is an example to create input Pop-Ups (Dialog) and get input from user −Examplepackage my; import javax.swing.JOptionPane; public class SwingDemo {    public static ... Read More

How to set vertical gap between elements in a GridLayout with Java?

George John

George John

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

1K+ Views

Use the setVgap() method to set the vertical gap between elements in a GridLayout. Let’s say we have a GridLaypout −GridLayout layout = new GridLayout(3, 3);Set the horizontal gap −layout.setVgap(30);The following is an example −Examplepackage my; import java.awt.Color; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Font; import java.awt.GridLayout; import javax.swing.JButton; import javax.swing.JFrame; ... Read More

Partial Functions in Python?

George John

George John

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

1K+ Views

Everybody loves to write reusable code, right? Then partial function is a cool thing to learn. Partial functions allows us to derive a function with x parameters to a function with fewer parameters and constant values set for the more limited function.We can write partial functional application in python through ... Read More

Advertisements