Aqua Phoenix
     >>  Lectures >>  Java 5  
 

Navigator
   
 
       
   

5.3 Swing widgets

Swing GUI components are instantiated and used in the same fashion as AWT GUI components.

AWT widget corresponding Swing widget
Label JLabel
Button JButton
Canvas JPanel
Checkbox JCheckBox
Choice JComboBox
List JList
TextField JTextField
TextArea JTextArea
Scrollbar JScrollBar
Table 5.1
Figure 5.1
  SwingComponents.java  
In addition, Swing introduces a large range of new components, only some of which are mentioned here:
  • JProgressBar
  • JPasswordField
  • JRadioButton
  • JSlider
  • JSpinner
  • JTable

Figure 5.2
  NewSwingComponents.java  

5.4 Layout Managers

The Swing environment uses the same LayoutManagers as AWT. Hence java.awt classes are still imported in Swing applications.

5.5 Event Listeners

Similarly, Event Listeners from AWT are also re-used. They were implemented for Swing GUI components. java.awt.event classes continue to be imported. Swing also defines new even listeners, found in javax.swing.event .