Java Reference
In-Depth Information
You can see here how a raised EtchedBorder edge to the buttons looks.
How It Works
Components laid out with a border layout manager are extended to fill the space available in the con-
tainer. The "NORTH" and "SOUTH" buttons are the full width of the window and the "EAST" and "WEST"
buttons occupy the height remaining unoccupied once the "NORTH" and "SOUTH" buttons are in place.
It always works like this, regardless of the sequence in which you add the buttons — the "NORTH" and
"SOUTH" components occupy the full width of the container and the "CENTER" component takes up the
remaining space. If there are no "NORTH" and "SOUTH" components, the "EAST" and "WEST" components
extend to the full height of the container.
The width of the "EAST" and "WEST" buttons is determined by the space required to display the button
labels. Similarly, the "NORTH" and "SOUTH" buttons are determined by the height of the characters in the
labels.
You can alter the spacing between components by passing arguments to the BorderLayout constructor
— the default gaps are zero. For example, you could set the horizontal gap to 20 pixels and the vertical
gap to 30 pixels with the following statement:
content.setLayout(new BorderLayout(20, 30));
Like the flow layout manager, you can also set the horizontal and vertical gaps individually by calling
the methods setHgap() and setVgap() for the BorderLayout object. For example:
BorderLayout border = new BorderLayout(); // Construct the object
content.setLayout(border); // Set the layout
Search WWH ::




Custom Search