Java Reference
In-Depth Information
The Swing component set is one big group of components. While the JDK 5.0 release
didn't add any new Swing components to the mix, logically, you can think of them as those
with duplicate components within AWT and those without.
AWT Component Replacements
The Swing component set was originally created because the basic AWT components that came
with the original version of the Java libraries were insufficient for real-world, forms-based
applications. All the basic components were there, but the existing set was too small and far
too restrictive. For instance, you couldn't even put an image on a button. To alleviate this situ-
ation, the Swing component set offers replacements for each of the AWT components. The
Swing components support all the capabilities of the original set and offer a whole lot more
besides. As such, you should never need to deal with any of the basic AWT components.
Note Although the Swing components replace the AWT components, you'll still need to understand
several basic AWT concepts, such as layout managers, event handling, and drawing support. In addition,
you'll need to grasp the concept that all of Swing is built on top of the core AWT libraries.
The basic distinction between the Swing and equivalent AWT components is, in most cases,
the Swing component class names begin with a J and the AWT ones don't. Swing's JButton is a
replacement for the AWT Button component. One exception is the JComboBox , which replaces
the AWT Choice component.
At the application programming interface (API) level, the Swing components are almost
always a superset of the features the AWT components support. While they support additional
capabilities, the basic AWT capabilities are there for everything but the JList component,
whose API is completely unlike that of the AWT List component. Table 1-1 maps the original
AWT components to their replacement Swing components.
Table 1-1. AWT to Swing Component Mapping
AWT Component
Nearest Swing Replacement
Button
JButton
Canvas
JPanel
Checkbox
JCheckBox
Checkbox in CheckboxGroup
JRadioButton in ButtonGroup
Choice
JComboBox
Component
JComponent
Container
JPanel
Label
JLabel
List
JList
 
Search WWH ::




Custom Search