Using the Abstract Windowing Toolkit

As a platform-neutral language, Java makes many of the details of graphical user interface (GUI) programming invisible, but they don't go away. As you saw in Chapter 36, "Developing Java Applets," you can build a simple applet with a GUI interface in just 10 lines of code. It takes just a few more lines to add a main() routine and a standalone Frame, enabling the applet to double as a GUI application. (Listing 37.1 shows such a program.)

Code Listing 37.1. HelloApplication.java—You Can Write an Applet That Will Also Run as an Application
 import java.applet.*; import java.awt.*; import java.awt.event.*; public class HelloApplication extends Applet { public static void main(String[] args) { HelloApplicationFrame ...

Get Platinum Edition Using XHTML™, XML, and Java™ 2 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.