Java Reference
In-Depth Information
Figure 4
A Combo Box, Check Boxes, and Radio Buttons
791
792
There are a large number of border types. We will show only a couple of variations
and leave it to the border enthusiasts to look up the others in the Swing
documentation. The EtchedBorder class yields a border with a
three-dimensional, etched effect. You can add a border to any component, but most
commonly you apply it to a panel:
JPanel panel = new JPanel();
panel.setBorder(new EtchedBorder());
If you want to add a title to the border (as in Figure 4 ), you need to construct a
TitledBorder . You make a titled border by supplying a basic border and then
the title you want. Here is a typical example:
panel.setBorder(new TitledBorder(new
EtchedBorder(), "Size"));
Search WWH ::




Custom Search