Swing

Java Swing Components (Advanced AWT)

Following links give you the Swing components – programs, output screen and explanation. Swing basics 1. Java JFC Swing Introduction 2. Swing Overview Are you interested in Swing – Input and Output? 1. Output: Swing JOptionPane – Displaying Message 2. Input: Swing JOptionPane – Taking User Input Total 4 programs are given on JButton: 1. …

Java Swing Components (Advanced AWT) Read More »

ProgressMonitor Example Java Swing

ProgressMonitor monitors the progress of the operation. Displays in percentage of completion of the operation. Example on ProgressMonitor import java.awt.*; import java.awt.event.*; import javax.swing.*; public class ProgressiveTest { public static void main (String args[]) { JFrame frame = new JFrame(“Swing’s ProgressMonitor”); JButton button = new JButton(“Start Iteration”); frame.getContentPane().add(button, BorderLayout.CENTER); int min = 0; int max …

ProgressMonitor Example Java Swing Read More »

BoxLayout Manager Example Java Swing

BoxLayout lays out the components in a horizontal or vertical line. An axis – either BoxLayout.X-AXIS or BoxLayout.Y-AXIS is specified at the time of construction and determines the orientation of the components. Components laid out along the x-axis are laid out horizontally, and components laid out along the y-axis are laid out vertically. Components are …

BoxLayout Manager Example Java Swing Read More »

JColorChooser Example Java Swing

Swing JColorChooser gets your own color palette. The color you selected either with RGB or HSB style can be applied to any Swing component. In the program,it is applied to Container (indirectly to JFrame). Example on JColorChooser import java.awt.*; import java.awt.event.*; import javax.swing.*; public class JColorChooserDemo extends JFrame implements ActionListener { JButton btn; Color clr; …

JColorChooser Example Java Swing Read More »

JDesktopPane Example Java Swing

JDesktopPane – Multiple Document Interface (MDI) Many of today’s applications use a multiple document interface (MDI) [i.e., a main window (often called the parent window) containing other windows (often called child windows)] to manage several open documents that are being processed in parallel. Many commercial Window products such as Microsoft PowerPoint, Corel Draw, Symantec Visual …

JDesktopPane Example Java Swing Read More »

JList Multiple Selection Example Java Swing

In the previous program, you have seen JList with single selection. Now let us go for JList Multiple Selection. In the following JList Multiple Selection example, user’s multiple selected items are displayed in JOptionPane using showMessageDialog() method. import javax.swing.*; import java.awt.*; import java.awt.event.*; import javax.swing.event.*; // for ListSelectionListener public class MultiSelectionDemo extends JFrame implements ListSelectionListener …

JList Multiple Selection Example Java Swing Read More »

JRadioButton and Button Group Example Java

This is an exclusive program on JRadioButton and ButtonGroup. To group six radio buttons, two objects of ButtonGroup are created and for each group three radio buttons are added. User’s selection is displayed using JOptionPane showMessageDialog() method. There is no counterpart class for this class in java.awt package; it is a new introduction in javax.swing …

JRadioButton and Button Group Example Java Read More »