|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jgoodies.forms.builder.AbstractFormBuilder
com.jgoodies.forms.builder.PanelBuilder
public class PanelBuilder
An general purpose panel builder that uses the FormLayout
to layout JPanel
s. It provides convenience methods
to set a default border and to add labels, titles and titled separators.
The PanelBuilder is the working horse for layouts when more specialized
builders like the ButtonBarBuilder
or com.jgoodies.forms.extras.DefaultFormBuilder
are inappropriate.
The Forms tutorial includes several examples that present and compare different style to build with the PanelBuilder: static row numbers vs. row variable, explicit CellConstraints vs. builder cursor, static rows vs. dynamically added rows. Also, you may check out the Tips & Tricks section of the Forms HTML documentation.
Example:
This example creates a panel with 3 columns and 3 rows.
FormLayout layout = new FormLayout( "right:pref, 6dlu, 50dlu, 4dlu, default", // columns "pref, 3dlu, pref, 3dlu, pref"); // rows PanelBuilder builder = new PanelBuilder(layout); CellConstraints cc = new CellConstraints(); builder.addLabel("Label1", cc.xy (1, 1)); builder.add(new JTextField(), cc.xywh(3, 1, 3, 1)); builder.addLabel("Label2", cc.xy (1, 3)); builder.add(new JTextField(), cc.xy (3, 3)); builder.addLabel("Label3", cc.xy (1, 5)); builder.add(new JTextField(), cc.xy (3, 5)); builder.add(new JButton("..."), cc.xy (5, 5)); return builder.getPanel();
com.jgoodies.forms.extras.I15dPanelBuilder
,
com.jgoodies.forms.extras.DefaultFormBuilder
Constructor Summary | |
---|---|
PanelBuilder(FormLayout layout)
Constructs an instance of PanelBuilder for the given
layout. |
|
PanelBuilder(javax.swing.JPanel panel,
FormLayout layout)
Constructs an instance of PanelBuilder for the given
panel and layout. |
Method Summary | |
---|---|
javax.swing.JLabel |
add(javax.swing.JLabel label,
CellConstraints labelConstraints,
java.awt.Component component,
CellConstraints componentConstraints)
Adds a label and component to the panel using the given cell constraints. |
javax.swing.JLabel |
addLabel(java.lang.String textWithMnemonic)
Adds a textual label to the form using the default constraints. |
javax.swing.JLabel |
addLabel(java.lang.String textWithMnemonic,
CellConstraints constraints)
Adds a textual label to the form using the specified constraints. |
javax.swing.JLabel |
addLabel(java.lang.String textWithMnemonic,
CellConstraints labelConstraints,
java.awt.Component component,
CellConstraints componentConstraints)
Adds a label and component to the panel using the given cell constraints. |
javax.swing.JLabel |
addLabel(java.lang.String textWithMnemonic,
java.lang.String encodedConstraints)
Adds a textual label to the form using the specified constraints. |
javax.swing.JComponent |
addSeparator(java.lang.String text)
Adds a titled separator to the form that spans all columns. |
javax.swing.JComponent |
addSeparator(java.lang.String text,
CellConstraints constraints)
Adds a titled separator to the form using the specified constraints. |
javax.swing.JComponent |
addSeparator(java.lang.String text,
int columnSpan)
Adds a titled separator to the form that spans the specified columns. |
javax.swing.JComponent |
addSeparator(java.lang.String text,
java.lang.String encodedConstraints)
Adds a titled separator to the form using the specified constraints. |
javax.swing.JLabel |
addTitle(java.lang.String text)
Adds a title label to the form using the default constraints. |
javax.swing.JLabel |
addTitle(java.lang.String text,
CellConstraints constraints)
Adds a title label to the form using the specified constraints. |
javax.swing.JLabel |
addTitle(java.lang.String text,
java.lang.String encodedConstraints)
Adds a title label to the form using the specified constraints. |
javax.swing.JPanel |
getPanel()
Returns the panel used to build the form. |
void |
setBorder(javax.swing.border.Border border)
Sets the panel's border. |
void |
setDefaultDialogBorder()
Sets the default dialog border. |
Methods inherited from class com.jgoodies.forms.builder.AbstractFormBuilder |
---|
add, add, add, appendColumn, appendColumn, appendGlueColumn, appendGlueRow, appendRelatedComponentsGapColumn, appendRelatedComponentsGapRow, appendRow, appendRow, appendUnrelatedComponentsGapColumn, appendUnrelatedComponentsGapRow, getColumn, getColumnCount, getContainer, getLayout, getRow, getRowCount, isLeftToRight, nextColumn, nextColumn, nextLine, nextLine, nextRow, nextRow, setAlignment, setBounds, setColumn, setColumnSpan, setExtent, setHAlignment, setLeftToRight, setOrigin, setRow, setRowSpan, setVAlignment |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PanelBuilder(javax.swing.JPanel panel, FormLayout layout)
PanelBuilder
for the given
panel and layout.
panel
- the layout container to build onlayout
- the form layout to usepublic PanelBuilder(FormLayout layout)
PanelBuilder
for the given
layout. Uses an instance of JPanel
as layout container.
layout
- the form layout to useMethod Detail |
---|
public final javax.swing.JPanel getPanel()
public final void setBorder(javax.swing.border.Border border)
border
- the border to setpublic final void setDefaultDialogBorder()
public final javax.swing.JLabel addLabel(java.lang.String textWithMnemonic, CellConstraints constraints)
textWithMnemonic
- the label's text - may contain a mnemonic markerconstraints
- the label's cell constraints
public final javax.swing.JLabel addLabel(java.lang.String textWithMnemonic, java.lang.String encodedConstraints)
textWithMnemonic
- the label's text - may contain a mnemonic markerencodedConstraints
- a string representation for the constraints
public final javax.swing.JLabel addLabel(java.lang.String textWithMnemonic)
textWithMnemonic
- the label's text - may contain a mnemonic marker
public final javax.swing.JLabel add(javax.swing.JLabel label, CellConstraints labelConstraints, java.awt.Component component, CellConstraints componentConstraints)
label
- the label to addlabelConstraints
- the label's cell constraintscomponent
- the component to addcomponentConstraints
- the component's cell constraints
JLabel.setLabelFor(java.awt.Component)
public final javax.swing.JLabel addLabel(java.lang.String textWithMnemonic, CellConstraints labelConstraints, java.awt.Component component, CellConstraints componentConstraints)
textWithMnemonic
- the label's text - may contain a mnemonic markerlabelConstraints
- the label's cell constraintscomponent
- the component to addcomponentConstraints
- the component's cell constraints
JLabel.setLabelFor(java.awt.Component)
public final javax.swing.JLabel addTitle(java.lang.String text, CellConstraints constraints)
text
- the label's title textconstraints
- the separator's cell constraints
public final javax.swing.JLabel addTitle(java.lang.String text, java.lang.String encodedConstraints)
text
- the label's textencodedConstraints
- a string representation for the constraints
public final javax.swing.JLabel addTitle(java.lang.String text)
text
- the separator titel
public final javax.swing.JComponent addSeparator(java.lang.String text, CellConstraints constraints)
text
- the separator titleconstraints
- the separator's cell constraints
public final javax.swing.JComponent addSeparator(java.lang.String text, java.lang.String encodedConstraints)
text
- the separator titelencodedConstraints
- a string representation for the constraints
public final javax.swing.JComponent addSeparator(java.lang.String text, int columnSpan)
text
- the separator titelcolumnSpan
- the number of columns the separator spans
public final javax.swing.JComponent addSeparator(java.lang.String text)
text
- the separator titel
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |