13: Creating windows and applets

Bruce Eckel’s Thinking in Java Contents | Prev | Next

and
applets

The
original design goal of the graphical user interface (GUI) library in Java 1.0
was to allow the programmer to build a GUI that looks good on all platforms.

One
of Java’s primary design goals is to create
applets,
which are little programs that run inside a Web browser. Because they must be
safe, applets are limited in what they can accomplish. However, they are a
powerful tool in supporting client-side programming, a major issue for the Web.

In
this chapter you’ll first learn the use of the original “old”
AWT, which is still supported and used by many of the code examples that you
will come across. Although it’s a bit painful to learn the old AWT,
it’s necessary because you must read and maintain legacy code that uses
the old AWT. Sometimes you’ll even need to write old AWT code to support
environments that haven’t upgraded past Java 1.0
.
In the second part of the chapter you’ll learn about the structure of the
“new” AWT in Java 1.1

and see how much better the event model is. (If you can, you should use the
newest tools when you’re creating new programs.) Finally, you’ll
learn about the new JFC/Swing components, which can be added to Java 1.1 as a
library – this means you can use the library without requiring a full
upgrade to Java 1.2
.

Most
of the examples will show the creation of applets, not only because it’s
easier but also because that’s where the AWT’s primary usefulness
might reside. In addition you’ll see how things are different when you
want to create a regular application using the AWT, and how to create programs
that are both applets and applications so they can be run either inside a
browser or from the command line.

More by Author

Must Read