Java Reference
In-Depth Information
TOPIC
CONCEPT
Defining
Applets
The class
JApplet
is the base class for an applet. The
JFrame
class is a base class for an application win-
dow with a title bar, borders, and a menu.
Layout
Managers
The arrangement of components in a container is controlled by a layout manager.
Default
Layout
Managers
The default layout manager for the content pane of
JFrame
,
JApplet,
and
JDialog
objects is
Border-
Layout
.
Spring Lay-
out Man-
ager
A layout manager of type
SpringLayout
arranges components by applying constraints in the form of
Spring
objects to their edges.
Box Con-
tainers
A
Box
container can be used to arrange components or containers in rows and columns. A
Box
container
has
BoxLayout
as its layout manager. You can use multiple nested
Box
containers in combination to easily
create complex arrangements that otherwise might require
GridBagLayout
to be used.
Creating
Menus
A menu bar is represented by a
JMenuBar
object. Menu items can be objects of type
JMenu
,
JMenuItem
,
JCheckBoxMenuItem
, or
JRadioButtonMenuItem
.
Drop-down
Menus
You associate a drop-down menu with an object of type
JMenu
.
Menu
Shortcuts
and Accel-
erators
You can create a shortcut for a menu by calling its
setMnemonic()
method, and you can create an accel-
erator key combination for a menu item by calling its
setAccelerator()
method.