Java Gui
Java Gui
import java.awt.*;
COMPONENTS DESCRIPTION
JButton javax.swing.JButton a “push button”.
javax.swing.JLabel display area for a short text or an image, or
JLabel
both.
javax.swing.JCheckBox an item that can be selected or
JCheckBox deselected. By convention, any number of check boxes in a
group can be selected.
javax.swing.JRadioButton an item that can be selected or
deselected. Used with the ButtonGroup object to create a
JRadioButton
group of buttons in which only one button at a time can be
selected.
javax.swing.JComboBox a component that combines a button
JComboBox
or editable field and a drop-down list.
javax.swing.JTextField a lightweight component that allows the
JTextField
editing of a single line of text.
javax.swing.JPasswordField a lightweight component that
allows the editing of a single line of text where the view
JPasswordField
indicates something was type, but doesn’t show the original
characters.
Difference between AWT and Swing
There are many differences between java awt and swing that are given below.
The GUI allows the user to interact with the program by generating events. These interactions can
be evoked by moving the mouse, clicking the mouse, selecting menu, typing in a textbox, closing a
window, and others. These interactions pass through events handlers, calling a method as
triggered by the event.
Label is normally used to hold text on the form. Although there are several ways to display text,
the Label control enables you to post messages on the form that can be changed by setting the
Label’s text property.
TextBox is used either displays a text or accept input from the user. Like for example, the
username textbox allows user to input their usernames and the password textbox allows users to
enter password.
A Button is a corner stone of almost all java application. With this control, user can be activated an
event that calls a method or a procedure.
Menus java.swing.JMenuBar;
Menus are essential element of GUIs. It is used to organized set of related commands without
cluttering the interface. Menus contains commands called menu items. Other menu may contain
additional submenus within a menu.