0% found this document useful (0 votes)
2 views8 pages

Java Swing GUI Components Overview

The document contains Java programs demonstrating the use of Swing and AWT components, including buttons and checkboxes. It provides examples of creating a JFrame with buttons, a Frame with multiple buttons, and a Frame with checkboxes for selecting languages. Additionally, it lists various Swing classes and their descriptions, such as JButton, JLabel, and JProgressBar, highlighting their functionalities.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views8 pages

Java Swing GUI Components Overview

The document contains Java programs demonstrating the use of Swing and AWT components, including buttons and checkboxes. It provides examples of creating a JFrame with buttons, a Frame with multiple buttons, and a Frame with checkboxes for selecting languages. Additionally, it lists various Swing classes and their descriptions, such as JButton, JLabel, and JProgressBar, highlighting their functionalities.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

// Java program using label (swing)

// to display the message “GFG WEB Site Click”

import [Link].*;

import [Link].*;

// Main class

class GFG {

// Main driver method

public static void main(String[] args)

// Creating instance of JFrame

JFrame frame = new JFrame();

// Creating instance of JButton

JButton button = new JButton(" GFG WebSite Click");

// x axis, y axis, width, height

[Link](150, 200, 220, 50);

// adding button in JFrame

[Link](button);

// 400 width and 500 height

[Link](500, 600);

// using no layout managers

[Link](null);

// making the frame visible

[Link](true);
}

// Java program to create three buttons

// with caption OK, SUBMIT, CANCEL

import [Link].*;

class button {

button()

Frame f = new Frame();

// Button 1 created

// OK button

Button b1 = new Button("OK");


[Link](100, 50, 50, 50);

[Link](b1);

// Button 2 created

// Submit button

Button b2 = new Button("SUBMIT");

[Link](100, 101, 50, 50);

[Link](b2);

// Button 3 created

// Cancel button

Button b3 = new Button("CANCEL");

[Link](100, 150, 80, 50);

[Link](b3);

[Link](500, 500);

[Link](null);

[Link](true);

public static void main(String a[]) { new button(); }

}
// Java Swing Program to Add Checkbox

// in the Frame

import [Link].*;

// Driver Class

class Lan {

// Main Function

Lan()

// Frame Created

Frame f = new Frame();

Label l1 = new Label("Select known Languages");

[Link](100, 50, 120, 80);

[Link](l1);
// CheckBox created

Checkbox c2 = new Checkbox("Hindi");

[Link](100, 150, 50, 50);

[Link](c2);

// CheckBox created

Checkbox c3 = new Checkbox("English");

[Link](100, 200, 80, 50);

[Link](c3);

// CheckBox created

Checkbox c4 = new Checkbox("marathi");

[Link](100, 250, 80, 50);

[Link](c4);

[Link](500, 500);

[Link](null);

[Link](true);

public static void main(String ar[]) { new Lan(); }

}
Components of Swing Class the task's percentage
Class Description

A Component is the Abstract base class for


about the non-menu user-interface controls
Component of Java SWING. Components are
representing an object with a graphical
representation.

A Container is a component that can


Container
container Java SWING Components

A JComponent is a base class for all swing


UI Components In order to use a swing
component that inherits from JComponent,
JComponent
the component must be in a containment
hierarchy whose root is a top-level Java
Swing container.
Class Description

A JLabel is an object component for placing


JLabel
text in a container.

JButton This class creates a labeled button.

A JColorChooser provides a pane of


JColorChooser controls designed to allow the user to
manipulate and select a color.

A JCheckBox is a graphical (GUI)


JCheckBox component that can be in either an on-
(true) or off-(false) state.

The JRadioButton class is a graphical (GUI)


JRadioButton component that can be in either an on-
(true) or off-(false) state. in the group

A JList component represents the user with


JList
the scrolling list of text items.

A JComboBox component is Presents the


JComboBox
User with a show up Menu of choices.

A JTextField object is a text component that


JTextField will allow for the editing of a single line of
text.

JPasswordField A JPasswordField object it is a text


component specialized for password entry.

A JTextArea object is a text component that


JTextArea allows for the editing of multiple lines of
text.

A ImageIcon control is an implementation of


Imagelcon the Icon interface that paints Icons from
Images

JScrollbar A JScrollbar control represents a scroll bar


Class Description

component in order to enable users to


Select from range values.

JOptionPane provides set of standard


JOptionPane dialog boxes that prompt users for a value
or Something.

A JFileChooser it Controls represents a


JFileChooser dialog window from which the user can
select a file.

As the task progresses towards completion,


JProgressBar the progress bar displays the tasks
percentage on its completion.

A JSlider this class is letting the user


JSlider graphically (GUI) select by using a value by
sliding a knob within a bounded interval.

A JSpinner this class is a single line input


where the field that lets the user select by
JSpinner
using a number or an object value from an
ordered sequence.

You might also like