public final class Forms extends Object
Modifier and Type | Method and Description |
---|---|
static JComponent |
border(Border border,
JComponent component)
Creates and returns a panel where
component is surrounded
by the given border. |
static JComponent |
border(String emptyBorderSpec,
JComponent component)
Creates and returns a panel where
component is surrounded
by an empty border as described by emptyBorderSpec . |
protected static JComponent |
buildGroupedButtonBar(AbstractButton... buttons)
Builds and returns a button bar that consists of the given buttons.
|
static JComponent |
buttonBar(JComponent... buttons)
Creates and returns a panel where the given buttons are laid out
using a ButtonBarBuilder.
|
static JComponent |
centered(JComponent component)
Creates and returns a panel where
component is centered. |
static JComponent |
checkBoxBar(JCheckBox... checkBoxes)
Builds and returns a panel where the given check boxes are laid out
in a row.
|
static JComponent |
horizontal(String gapColSpec,
JComponent... components)
Builds and returns a panel where the given components are laid out
horizontally separated by gaps as described by the given
FormLayout gap (column) specification.
|
static JComponent |
radioButtonBar(JRadioButton... radioButtons)
Builds and returns a panel where the given radio buttons are laid out
in a row.
|
static JComponent |
single(String columnSpec,
String rowSpec,
JComponent component)
Creates and returns a panel where
component is laid out
using a FormLayout with the given column and row specifications. |
static JComponent |
vertical(String gapRowSpec,
JComponent... components)
Builds and returns a panel where the given components are laid out
vertically separated by gaps as described by the given
FormLayout gap (row) specification.
|
public static JComponent single(String columnSpec, String rowSpec, JComponent component)
component
is laid out
using a FormLayout with the given column and row specifications.
Forms.single( "left:150dlu", "c:p", component); Forms.single( "fill:150dlu:grow", "f:20dlu", component); Forms.single("center:150dlu", "b:p:g", component);
columnSpec
- a FormLayout column specification for a single columnrowSpec
- a FormLayout row specification for a single rowcomponent
- the component to lay outNullPointerException
- if columnSpec
, rowSpec
,
or component
is null
IllegalArgumentException
- if columnSpec
or rowSpec
is empty or whitespacepublic static JComponent centered(JComponent component)
component
is centered.
The panel grows both horizontally and vertically as its container grows.
Forms.centered(anImageLabel); Forms.centered(anAnimatedPanel);
component
- the component to centerNullPointerException
- if component
is null
public static JComponent border(Border border, JComponent component)
component
is surrounded
by the given border.
Forms.border(Borders.DLU14, aComponent); Forms.border(new LineBorder(Color.GRAY), aComponent);
border
- the border used to surround the componentcomponent
- the component to wrapNullPointerException
- if border
or component
is null
public static JComponent border(String emptyBorderSpec, JComponent component)
component
is surrounded
by an empty border as described by emptyBorderSpec
.
Forms.border("4dlu, 0, 4dlu, 8dlu", aComponent); Forms.border("10px 4px, 10px, 4px", aComponent);
component
- the component to wrapNullPointerException
- if emptyBorderSpec
or component
is null
public static JComponent horizontal(String gapColSpec, JComponent... components)
Forms.horizontal("4dlu", component1, component2); Forms.horizontal("$rgap", component1, component2, component3); Forms.horizontal("0", component1, component2, component3);
gapColSpec
- describes the horizontal gap between the componentscomponents
- the components to be laid outNullPointerException
- if components
is null
IllegalArgumentException
- if components
is emptypublic static JComponent vertical(String gapRowSpec, JComponent... components)
Forms.vertical("4dlu", component1, component2); Forms.vertical("$rgap", component1, component2, component3); Forms.vertical("0", component1, component2, component3);
gapRowSpec
- describes the vertical gap between the componentscomponents
- the components to be laid outNullPointerException
- if components
is null
IllegalArgumentException
- if components
is emptypublic static JComponent buttonBar(JComponent... buttons)
new ButtonBarBuilder().addButton(buttons).build();
buttons
- the buttons to add to the button barNullPointerException
- if buttons
is null
IllegalArgumentException
- if buttons
is emptyButtonBarBuilder
public static JComponent checkBoxBar(JCheckBox... checkBoxes)
If class com.jgoodies.jsdl.common.focus.FocusTraversalUtils
from the JSDL Common library is in the class path,
it is used to group the radio buttons. Focus is transferred to/from
the selected button in a group; and cursor-left/-right change
the selection in the group.
checkBoxes
- the check boxes to lay out in a rowNullPointerException
- if checkBoxes
is null
IllegalArgumentException
- if checkBoxes
is emptypublic static JComponent radioButtonBar(JRadioButton... radioButtons)
If class com.jgoodies.jsdl.common.focus.FocusTraversalUtils
from the JSDL Common library is in the class path,
it is used to group the radio buttons. Focus is transferred to/from
the selected button in a group; and cursor-left/-right change
the selection in the group.
radioButtons
- the radio buttons to lay out in a rowNullPointerException
- if radioButtons
is null
IllegalArgumentException
- if radioButtons
is emptyprotected static JComponent buildGroupedButtonBar(AbstractButton... buttons)
FocusTraversalUtils
,
if in the classpath.Copyright © 2014 JGoodies Software GmbH. All rights reserved.