Chapter 11. Graphical User Interfaces

Graphical user interfaces, or GUIs, represent an excellent example of software modularity and reuse. GUIs are almost always assembled from libraries of predefined building blocks. To Motif programmers on Unix systems, these GUI building blocks are known as widgets. To Windows programmers, they are known as controls. In Java, they are known by the generic term components, because they are all subclasses of java.awt.Component.[1]

In Java 1.0 and 1.1, the standard library of GUI components was AWT—the package java.awt and its subpackages. There is debate as to what the letter A stands for in this acronym, but “WT” stands for “windowing toolkit.” In practice, it is always called AWT. In addition to GUI components, the AWT includes facilities for drawing graphics, performing cut-and-paste-style data transfer, and other related operations. On most platforms, AWT components are implemented using the operating-system’s native GUI system. That is, AWT components are implemented on top of Windows controls on Windows operating systems, on top of Motif widgets on Unix systems, and so on. This implementation style led to a least-common-denominator toolkit, and, as a result, the AWT API is not as complete and full featured as it should be.

Java 1.2 introduced a new library of GUI components known as Swing. Swing consists of the javax.swing package and its subpackages. Unlike the AWT, Swing has a platform-independent implementation and a state-of-the-art ...

Get Java Examples in a Nutshell, 3rd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.