SWINGS
RS NANDHINI
Introduction
• Java Swing is a part of Java Foundation Classes (JFC) that is used to
create window-based applications.
• It is built on the top of AWT API and entirely written in java.
• Unlike AWT, Java Swing provides platform-independent and
lightweight components.
• The [Link] package provides classes for java swing API such as
Jbutton, JTextField, JTextArea, JRadioButton, JCheckBox, Jmenu,
JColorChooser etc.
JAVA AWT JAVA SWING
AWT components are platform-dependent Java swing components are platform-
independent.
AWT components are heavyweight Swing components are lightweight.
AWT doesn’t support pluggable look and feel. Swing supports pluggable look and feel.
AWT provides less components than Swing Swing provides more powerful components
such as tables, lists, scrollpanes, colorchooser,
tabbedpane etc.
AWT doesn’t follow MVC (Model View Swing follow MVC.
Controller) where model represents data, view
represents presentation and controller acts as
an interface between model and view.
CLASS DESCRIPTION
AbstractButton Abstract superclass for Swing buttons.
ButtonGroup Encapsulates a mutually exclusive set of button.
ImageIcon Encapsulates an icon.
JApplet The Swing version of Applet.
JButton The Swing push button class
JCheckBox The Swing check box class.
JComboBox Encapsulates a combo box (a combination of drop-down
list and text field).
JLabel The Swing version of a label.
JRadioButton The Swing version of a radio button.
JScrollPanel Encapsulates a scrollable window.
JTabbedPane Encapsulates a tabbed window.
JTextField The Swing version of a text field.
JTree Encapsulates a tree-based control.
COMPONENTS OF JAVA SWING
JLabel
• Jlabel is a Java Swing component that displays text or image.
• It is commonly used to provide information or to label other
components.
JTextField
• JTextField is a component that allows the user to input text.
• It is commonly used to get input from the user, such as a name or an
address.
JButton
• JButton is a component that represents a clickable button.
• It is commonly used to trigger actions in a GUI application.
JCheckBox
• JCheckBox is a component that represents a checkbox.
• It is commonly used to get a binary input from the user, such as
whether or not to enable a feature.
JRadioButton
• The JRadioButton class is used to create a radio button.
• It is used to choose one option from multiple options.
• It is widely used in exam systems or quiz.
JList
• The object of JList class represents a list of text items.
• The list of text items can be set up so that the user can choose either
one item or multiple items.
• It inherits JComponent class.
JComboBox
• The object of choice class is used to show popup menu of choices.
• Choice selected by user is shown on the top of a menu.
• It inherits JComponent class.
JTabbedPane
• The JTabbedPane class is used to switch between a group of
components by clicking on a tab with a given title or icon. It inherits
Jcomponent class.