20-CS-694 Advanced Programming Techniques Spring 2012
AWT and Swing

Interfaces, Exceptions, Graphics, Animation, Threads, Reflection, Networking, RMI, JDBC, JNI

All lectures
Application Window Toolkit and Swing

This series shows how to use many of the classes associated with AWT and Swing widgets. Click on the class names in the following table to see class details.

AdjustmentListener ActionListener ItemEvent JTextArea JTextField
ItemListener ActionEvent AdjustmentEvent JFrame JComboBox
JMenu JMenuBar JMenuItem JScrollBar JScrollPane
Font FontMetrics JCheckBox CheckboxGroup JCheckBoxMenuItem

1.   F.java

  -   A JFrame may be opened from another JFrame and made visible and invisible using setVisible. Any state contained int the JFrame object remains intact.
 
2.   FrameTestApplet.java

  -   Like the above applet but this time JFrame objects can be destroyed with method dispose, resulting in a loss of state information.
 
3.   MenuTestApplet.java

  -   This is a simple demonstration of adding menus to a JFrame. Classes involved are: JMenuBar, JMenu, JMenuItem, JCheckBoxMenuItem. These menu items have ItemListeners which allow actions to be performed when menu items are selected.
 
4.   ColorApplet.java

  -   This is mainly a demonstration of JScrollBar objects but is interesting also for its use of color management methods Color.RGBtoHSB and Color.getHSBColor, and because AdjustmentListener have to be turned off and on while changes are being made to JScrollBar slider positions.
 
5.   CheckBoxApplet.java

  -   A simple demonstration of a Checkbox and CheckboxGroup which allows only one item to be checked in a group.
 
6.   CanvasApplet.java

  -   This demonstrates the use of a Canvas object and the use of Font and FontMetrics classes.
 
7.   CenterApplet.java

  -   Similar to the applet above except drawing is directly to a JFrame instead of a Canvas which gets bolted onto a JFrame.
 
8.   FontsApplet.java

  -   Draws a number of strings in various fonts to a JFrame.
 
9.   BorderlayoutApplet.java

  -   Puts two JPanel with BorderLayouts into a JFrame. Both panels are populated with JButton in all regions and spacing is set in one of the panels.
 
10.   GridlayoutApplet.java

  -   Same as above except for GridLayouts.
 
11.   ButtonsApplet.java

  -   Mixes the use of JButton, Font, Canvas and JPanel objects.
 
12.   ChoiceApplet.java

  -   Demonstrates the use of JTextField and JComboBox objects.
 
13.   TextApplet.java

  -   Demonstrates the use of JTextField and JButton objects.
 
14.   TextareaApplet.java

  -   Demonstrates some things that can be done to regions of a JTextArea: sections can be moved, copied, and so on.