In the architecture of the java swing we are going to show the swing components with classes. The swing components are contained in package called javax.swing. This package contains all the swing components and classes. The swing components inherit the classes from java.awt package. The java.awt package contains two types of classes are:
- Component
- Container
These classes are included in the java.awt package having the buttons, text fields, menus, labels, check boxes, scrollbars, popup menus etc. But these are not powerful when compared to swings and these are heavy weight.
Swing components are prefix with ‘J’. Every component of swing starts with J i.e. replacing components from AWT. The swing classes are contained javax.swing. This package holds all swing components and classes. This package holds JComponent which is having all the sub components. The hierarchy of JComponent will be sub divided into three levels. The classification of JComponent is:[15]
- Top level
- Intermediate level
- Swings other components
According to their functionality the components are classified. These all components are inherited and make use of javax.swing package.
The top level components include:
Abstract button: This button includes three more intermediate components are:
- JToggleButton
- JButton
- JMenuItem
- JToggleButton: This JToggleButton is parent component for other two child components. This component includes other two components are JCheckbox and JRadioButton.
JCheckbox: this is used to display user choices which are not common.
JRadioButton: this button is used to display common choices.
- JButton: This JButton is one type of push button. It can be used to display text or images or both.
- JMenuItem: It is used to select the item from given menu. It having one child component as JMenu used for pull-down menu.
JList: It is come under top level component. This component displays the user selected choice from given list. It also displays the random objects and more often choices include images or strings.
JOptionPane: this component is used to display simple dialog boxes. It describes helpful static methods to display different dialog types.
JPopupMenu: this component is utilized by JMenu and other popup menus which are standalone. This component is used by windows that will popup and menu displayed. [15]
JTextComponent: it is element of javax.swing.text package and its parent component of JTextArea and JTextField. This component is highly powerful and extremely customizable.
- JTextArea: this component is used to display text and editing text using for multiple lines from plain text.
- JTextField: this component is used to display input and editing text using for single line from plain text. It having the other child component as JPasswordField.
JPasswordField: it is used to hold the sensitive data like passwords. It is fully secured and it not showed data when we typed.
JMenuBar: This will display the pull-down menus.
JScrollPane: This component is to scroll horizontal and vertical.
- JLabel: this component is simple and used to display text and images. But this JLabel is not giving responds to input. And many more components are applicable in the swings to make GUI application.