Java Reference
In-Depth Information
want surplus space to be taken up. You can add glue at several positions in a row or column, and spare space
is distributed between the glue components. You can add glue after the last component in each column to
make all the spare space appear at the end of each column of buttons. For the radio buttons you can add the
following statement:
// Statements adding radio buttons to left Box object...
left.add(Box.createGlue()); // Glue at the end
TryBoxLayout3.java
You can do the same for the right box:
// Statements adding check boxes to right Box object...
right.add(Box.createGlue()); // Glue at the end
TryBoxLayout3.java
The glue component at the end of each column of buttons takes up all the surplus space in each vertical
Box container. This makes the buttons line up at the top. Running the program with added glue results in the
application window shown in Figure 17-25 .
FIGURE 17-25
It's better now, but let's put together a final version of the example with some additional embroidery.
TRY IT OUT: Embroidering Boxes
You use some JPanel objects with a new kind of border to contain the vertical Box containers:
 
 
Search WWH ::




Custom Search