* <code>Box</code> using the constructor and pass in
* <code>BoxLayout.PAGE_AXIS</code>, eg:
* <pre>
* Box lineBox = new Box(BoxLayout.PAGE_AXIS);
* </pre>
*
* @return the box
*/
public static Box createVerticalBox() {
return new Box(BoxLayout.Y_AXIS);
}
/**
* Creates an invisible component that's always the specified size.
* <!-- WHEN WOULD YOU USE THIS AS OPPOSED TO A STRUT? -->
*
* @param d the dimensions of the invisible component
* @return the component
* @see #createGlue
* @see #createHorizontalStrut
* @see #createVerticalStrut
*/
public static Component createRigidArea(Dimension d) {
return new Filler(d, d, d);
}
/**
* Creates an invisible, fixed-width component.
* In a horizontal box,
* you typically use this method
* to force a certain amount of space between two components.
* In a vertical box,
* you might use this method
* to force the box to be at least the specified width.
* The invisible component has no height
* unless excess space is available,
* in which case it takes its share of available space,
* just like any other component that has no maximum height.
*
* @param width the width of the invisible component, in pixels >= 0
* @return the component
* @see #createVerticalStrut
* @see #createGlue
* @see #createRigidArea
*/
public static Component createHorizontalStrut(int width) {
return new Filler(new Dimension(width,0), new Dimension(width,0),
new Dimension(width, Short.MAX_VALUE));
}
/**
* Creates an invisible, fixed-height component.
* In a vertical box,
* you typically use this method
* to force a certain amount of space between two components.
* In a horizontal box,
* you might use this method
* to force the box to be at least the specified height.
* The invisible component has no width
* unless excess space is available,
* in which case it takes its share of available space,
* just like any other component that has no maximum width.
*
* @param height the height of the invisible component, in pixels >= 0
* @return the component
* @see #createHorizontalStrut
* @see #createGlue
* @see #createRigidArea
*/
public static Component createVerticalStrut(int height) {
return new Filler(new Dimension(0,height), new Dimension(0,height),
new Dimension(Short.MAX_VALUE, height));
}
/**
* Creates an invisible "glue" component
* that can be useful in a Box
* whose visible components have a maximum width
* (for a horizontal box)
* or height (for a vertical box).
* You can think of the glue component
* as being a gooey substance
* that expands as much as necessary
* to fill the space between its neighboring components.
*
* <p>
*
* For example, suppose you have
* a horizontal box that contains two fixed-size components.
* If the box gets extra space,
* the fixed-size components won't become larger,
* so where does the extra space go?
* Without glue,
* the extra space goes to the right of the second component.
* If you put glue between the fixed-size components,
* then the extra space goes there.
* If you put glue before the first fixed-size component,
* the extra space goes there,
* and the fixed-size components are shoved against the right
* edge of the box.
=2= |