Java Reference
In-Depth Information
pane.add(labelJL, BorderLayout.NORTH);
pane.add(textAreaTA, BorderLayout.SOUTH);
pane.add(buttonJB, BorderLayout.EAST);
pane.add(checkboxCB, BorderLayout.WEST);
pane.add(radioButtonRB, BorderLayout.CENTER);
setVisible(
true
);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public static void
main(String[] args)
{
BorderLayoutExample flow =
new
BorderLayoutExample();
}
}
Sample Run: Asamplerunofthe
BorderLayoutExample
program is shown in
Figure 12-20.
FIGURE 12-20
Sample run of the
BorderLayoutExample
program
Menus
Menus allow you to provide various functions without cluttering the GUI with too many
components. Menus can be attached to objects, such as
JFrame
and
JApplet
.
The
class
es
JFrame
and
JApplet
both have the method
setJMenuBar
that allows you
to set a menu bar. To set a menu bar, say,
menuMB
, you need statements such as the
following:
Search WWH ::
Custom Search