- Swing contains two key items i.e components and containers.
- Components are independent visual controls.
- Conatiners builts a group of components.
- Swing Containers are of two types light-weight and heavy-weight.
- All components of swing are derived from JComponent class.
- JComponent do inherit component class and container class of awt.
- JFrame, JApplet, JDialog and JWindow these are all swing containers but they do not inherit JComponent instead they directly inherit component and container class of awt.
- Since awt is heavy-weight because it is platform independent, JFrame, JApplet, JDialog and JWindow do inherits awt component and container class and hece they are also heavy-weight.
- Top-level containers are not containd within any other container.
- All the swing component which inherits JComponent class are light-weight.
- An example of light-weight container is JPanel which is a general purpose container.
- Swing components are available in javax.swing package and some of the swing events which are not defined in AWTEvent class are present in javax.swing.event package
✭Swing components Constructor
- JButton
- JButton();
- JButton(String str);
- JButton(ImageIcon image);
- JButton(String str, ImageIcon image);
- JLabel
- JLabel();
- JLabel(String str);
- JLabel(Icon image);
- JLabel(String str, Icon image, int horizotalAlignment);
- JLabel(String str, int horizotalAlignment);
- JRadioButton
- JRadioButton()
- JRadioButton(Action a)
- JRadioButton(Icon icon, boolean selected)
- JRadioButton(String text, boolean selected)RadioButton(String text, Icon icon)
- JRadioButton(String text, Icon icon, boolean selected)
- JComboBox
- JComboBox()
- JComboBox(ComboBoxModel aModel)
- JComboBox(Object[] items)
- JComboBox(Vector<?> items)