Comparing Swing to the AWT
Although you won't be exploring Swing until the next chapter, you might want to see an example of how Swing compares to the AWT. AWT and Swing versions of a small application are presented here. The first version is called AWTHello, and its source code is presented in Listing 15.2.
Code Listing 15.2. The AWTHello Application Source Code
// AWTHello.java import java.awt.*; import java.awt.event.*; class AWTHello extends Frame implements ActionListener { Button b; static String [] labels = { "Hello! Welcome to AWT!", "You cannot assign icons to AWT buttons." }; int nextLabel; AWTHello (String title) { super (title); addWindowListener (new WindowAdapter () { public void windowClosing (WindowEvent e) { System.exit (0); ... |
Get Special Edition Using Java 2 Standard Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.