JFrame with JLabel

JLabel is the Swing component that creates a label, which is a component that displays information. The label is Swing’s simplest component because it is passive. That is, a label does not respond to user input. It just displays output. The program uses a JFrame container to hold an instance of a JLabel. The label … Read more…

extends JFrame

The JFrame is a class like any other and can be extended. Program       Program Source import javax.swing.JFrame; class Frame extends JFrame{ Frame() { setTitle(“First java GUI application”); setSize(700, 200); setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } } public class Javaapp { public static void main(String[] args) { Frame frame = new Frame(); } }

Java-Swing

Swing The Swing package in Java enables the programmers to create Graphical User Interface applications. It contains a number of classes that help to implement Windows-based tasks, such as manipulating windows, adding scroll bars, buttons, list items, text boxes, etc. All the classes are contained in the javax.swing package. These classes are hierarchically arranged inside … Read more…

JOptionPane showConfirmDialog with YES_NO_OPTION and ImageIcon

Show a message and get a conformation (like Ok/Cancel).The showConfirmDialog return integers to indicate which button the user choose. For the confirmation dialog, the return value can be one of the following : OK_OPTION CANCEL_OPTION YES_OPTION NO_OPTION CLOSED_OPTION Program       Program Source import javax.swing.JOptionPane; import javax.swing.ImageIcon; public class Javaapp { public static void … Read more…

JOptionPane showConfirmDialog

Show a message and get a conformation (like Ok/Cancel).The showConfirmDialog return integers to indicate which button the user choose. For the confirmation dialog, the return value can be one of the following : OK_OPTION CANCEL_OPTION YES_OPTION NO_OPTION CLOSED_OPTION Program       Program Source import javax.swing.JOptionPane; public class Javaapp { public static void main(String[] args) … Read more…

JOptionPane showInputDialog with Selection String

showInputDialog() Show a message and get one line of user input. The input dialog has an additional component for user input. This can be a text field into which the user can type an arbitrary string. Program       Program Source import javax.swing.JOptionPane; import javax.swing.ImageIcon; public class Javaapp { public static void main(String[] args) … Read more…