Professional Documents
Culture Documents
-Is a part of Java Foundation Classes (JFC) that is used to create window-
based applications. It is built on the top of AWT (Abstract Windowing Toolkit) API
and entirely written in java.
-JFC :-The Java Foundation Classes (JFC) are a set of GUI components which
simplify the development of desktop applications.
-The javax.swing package provides classes for java swing API such as JButton,
JTextField, JTextArea, JRadioButton, JCheckbox, JMenu, JColorChooser etc.
2.Data Transfer
4.Accessibility
1-Top-Level/Internal Containers,Ex:-JFrame
4-Basic Controls
Unlike Frame, JFrame has the option to hide or close the window with the
help of setDefaultCloseOperation(int) method.
import javax.swing.JFrame;
public class JFrameExample {
JFrame frame = new JFrame("JFrame Example"); }
-Inherits JComponents
* JDialog :-
The JDialog control represents a top level window with a border and a title
used to take some form of input from the user. It inherits the Dialog class.
public class JPanel extends JComponent implements Accessible
*JToolBar :-
Nested Classes
Modifier and Class Description
Type
public class JScrollPaneExample;
3. SPECIAL PURPOSE CONTAINERS :-
*JLayeredPane :-
public class JLayeredPane extends JComponent implements
Accessible;
*JRootPane :-
import javax.swing.JRootPane;
public class JRootPaneExample;
4. BASIC CONTROLS :-
*JButton :-
The JButton class is used to create a labeled button that has platform
independent implementation. The application result in some action when the
button is pushed. It inherits AbstractButton class.
JButton class declaration
declaration for javax.swing.JButton class.
public class JButton extends AbstractButton implements Accessible
*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.
JComboBox class declaration
Let's see the declaration for javax.swing.JComboBox class.
public class JComboBox extends JComponent implements ItemSelectable, ListD
ataListener, ActionListener, Accessible;
*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.
JList class declaration
Let's see the declaration for javax.swing.JList class.
public class JList extends JComponent implements Scrollable,
Accessible;
*JMenu :-
The object of JMenu class is a pull down menu component which is displayed from
the menu bar. It inherits the JMenuItem class.
The object of JMenuItem class adds a simple labeled menu item. The items used in
a menu must belong to the JMenuItem or any of its subclass.
*JLabel :-
JLabel class is used to render a read-only text label or images on the
UI. It does not generate any event.
JLabel class declaration :-
JLabel textLbl = new JLabel(“This is a text label.”);
public class JProgressBar extends JComponent implements SwingConstants, Acc
essible;
*JTextArea :-
The object of a JTextArea class is a multi line region that displays text.
It allows the editing of multiple line text. It inherits JTextComponent class
public class JTextArea extends JTextComponent
*JTable :-
The JTable class is used to display data in tabular form. It is
composed of rows and columns.
*JColorChooser :-
The JColorChooser class is used to create a color chooser dialog box
so that user can select any color. It inherits JComponent class.
JColorChooser class declaration :-
Let's see the declaration for javax.swing.JColorChooser class.
public class JColorChooser extends JComponent implements Accessible
*JFilleChooser :-
public class JFileChooser extends JComponent implements
Accessible;
*JTree:-
The JTree class is used to display the tree structured data or hierarchical
data. JTree is a complex component. It has a 'root node' at the top most
which is a parent for all nodes in the tree. It inherits JComponent class.
JTree class declaration :-
Let's see the declaration for javax.swing.JTree class.
public class JTree extends JComponent implements Scrollable, Accessible