Java Reference
In-Depth Information
Component
Container
JComponent
JPanel
AbstractButton
JLabel
JTextComponent
JTextField
JButton
JToggleButton
JCheckBox
JRadioButton
FIGURE 9.7 Part of the GUI component class hierarchy
graphics classes in Java. Swing classes were introduced later, adding components
that provided much more functionality than their AWT counterparts. We use
Swing components in our examples in this topic. In the component class hierar-
chy, some Swing classes are ultimately derived from AWT classes.
Both Container and Component are original AWT classes. The Component class
contains much of the general functionality that applies to all GUI components,
such as basic painting and event handling. So although we may prefer to use
some of the specific Swing components, they are based on core AWT concepts
and respond to the same events as AWT components. Because they are derived
from Container , many Swing components can serve as containers, though in most
circumstances those abilities are curtailed. For example, we've seen that a JLabel
object can contain an image, but it cannot be used as a generic container to which
any component can be added.
Many features that apply to all Swing components are defined in the
JComponent class and are inherited into its descendants. For example, we have the
 
 
Search WWH ::




Custom Search