Java Reference
In-Depth Information
are considered as optional packages and are not shipped with any of the official
editions.) Smaller platforms, such as cell phones and PDAs, often do not contain
sufficient memory for Swing to run and therefore Swing does not appear in the
J2ME edition of Java. (We briefly describe J2ME in Chapter 24.)
Swing brought a huge improvement in the GUI with new capabilities that
ranged from buttons showing icons to checkboxes to tables with multiple columns
and rows. Swing came as part of the Java Foundation Classes (JFC) set of pack-
ages that also include:
Pluggable Look and Feel - the style of the components, such as the color scheme and
design, can be customized and can look the same regardless of the platform
Accessibility API - modifies the interface for easier use by the disabled
Drag and Drop - provides for moving data between Java programs and other programs
running on the native host
Java 2D - an expanded set of drawing tools
6.4 Swing class hierarchy
The Swing classes build upon the lower level classes of the original AWT graphics
packages. As the diagram in Figure 6.2 shows, the Swing user interface compo-
nents extend from the Container and Component classes in java.awt . The
diagram shows only a subset of the Swing components and how they extend the
AW T components (the diagram omits some Swing components like JTable ).
Most visual component classes begin with the letter ā€œJā€ while there are various
supporting classes in the javax.swing packages that don't begin with ā€œJ.ā€
The JComponent subclasses are lightweight, so they run inside a single
heavyweight high-level component, such as JFrame and JDialog , and draw and
re-draw themselves completely with Java; no other native code peer components
are involved. Combined with the event handling process described in Chapter 7,
Swing components provide very flexible and elaborate GUI tools. One can also
develop custom components in a straightforward manner by extending either
JComponent or one of its subclasses.
The number of Swing classes and their depth and complexity is far greater
than with the AWT. We cover a number of aspects of Swing in this and later
chapters. However, we can only touch on a small fraction of Swing's capabilities.
To describe all of the classes, one popular topic for Swing programming requires
more than 1600 pages [1]! Another useful Swing reference is Sun's Java Swing
tutorial [2].
As we indicated earlier, a drawback of this huge graphics resource is the large
amount of memory that Swing GUI programs can absorb when many components
are involved. Another problem comes from the fact that the browser on many
desktop machines still does not include a Java 1.2 (or later) JVM. So applets with
Swing components will not run in all browsers. In the Web Course Chapter 1 we
Search WWH ::




Custom Search