O'Reilly logo

Special Edition Using Java 2 Standard Edition by Geoff Friesen, Chuck Cavaness, Brian Keeton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required