Java Reference
In-Depth Information
of GraphicsPanelExample have the same height, 50 , but they have different
widths. An instance of this class is shown in Fig. 17.7, without colors.
17.2.5
Components versus containers
A container is an object that can contain displayable components . JFrame is an
example of a container, and JButton is an example of a component.
Some components are themselves containers, so one can create components
within other components. This provides a great deal of (needed) flexibility in cre-
ating GUIs.
Figure 17.8 contains a partial hierarchy of components in the GUI system.
In the case of Button and JButton , Button is in the old package java.awt and
JButton is in the new package javax.swing . There are many other such cases.
We have omitted many classes from the hierarchy, including layout man-
agers (like BorderLayout ) and classes that deal with menus.
Component
Box, Filler, Button, Canvas
Checkbox, Choice
Label, List, Scrollbar
TextComponent
TextField, TextArea
Container
JComponent
AbstractButton
JButton
JToggleButton
JCheckBox
RadioButton
JLabel, JList
JOptionPane, JPanel
JPopupMenu, JScrollBar
JSlider
JTextComponent
JTextField, JTextArea
Panel
Applet
JApplet
ScrollPane
Window
Frame
JFrame
JWindow
Figure 17.8:
Partial hierarchy of components and containers
Search WWH ::




Custom Search