|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.richclient.layout.GridBagLayoutBuilder
public class GridBagLayoutBuilder
This provides an easy way to create panels using a GridBagLayout
.
GridBagLayoutBuilder builder = new GridBagLayoutBuilder(); builder.appendRightLabel("label.field1").appendField(field1); builder.appendRightLabel("label.field2").appendField(field2); builder.nextLine(); builder.appendRightLabel("label.field3").appendField(field3); // because "field3" is the last component on this line, but the panel has // 4 columns, "field3" will span 3 columns builder.nextLine(); // once everything's been put into the builder, ask it to build a panel // to use in the UI. JPanel panel = builder.getPanel();
setAutoSpanLastComponent(boolean)
,
setShowGuidelines(boolean)
,
setComponentFactory(ComponentFactory)
Constructor Summary | |
---|---|
GridBagLayoutBuilder()
|
Method Summary | |
---|---|
GridBagLayoutBuilder |
append(Component component)
Appends the given component to the end of the current line, using the default insets and no expansion |
GridBagLayoutBuilder |
append(Component component,
int colSpan,
int rowSpan)
Appends the given component to the end of the current line, using the default insets and no expansion |
GridBagLayoutBuilder |
append(Component component,
int colSpan,
int rowSpan,
boolean expandX,
boolean expandY)
Appends the given component to the end of the current line, using the default insets |
GridBagLayoutBuilder |
append(Component component,
int colSpan,
int rowSpan,
boolean expandX,
boolean expandY,
Insets insets)
Appends the given component to the end of the current line |
GridBagLayoutBuilder |
append(Component component,
int colSpan,
int rowSpan,
double xweight,
double yweight)
Appends the given component to the end of the current line, using the default insets |
GridBagLayoutBuilder |
append(Component component,
int colSpan,
int rowSpan,
double xweight,
double yweight,
Insets insets)
Appends the given component to the end of the current line |
GridBagLayoutBuilder |
append(Component component,
int x,
int y,
int colSpan,
int rowSpan,
boolean expandX,
boolean expandY,
Insets insets)
Appends the given component to the end of the current line |
GridBagLayoutBuilder |
append(Component component,
int x,
int y,
int colSpan,
int rowSpan,
double xweight,
double yweight,
Insets insets)
Appends the given component to the end of the current line |
GridBagLayoutBuilder |
appendField(Component component)
Appends the given component to the end of the current line. |
GridBagLayoutBuilder |
appendField(Component component,
int colSpan)
Appends the given component to the end of the current line. |
GridBagLayoutBuilder |
appendLabel(JLabel label)
Appends the given label to the end of the current line. |
GridBagLayoutBuilder |
appendLabel(JLabel label,
int colSpan)
Appends the given label to the end of the current line. |
GridBagLayoutBuilder |
appendLabeledField(JLabel label,
JComponent field,
LabelOrientation labelOrientation,
int colSpan,
int rowSpan,
boolean expandX,
boolean expandY)
Appends a label and field to the end of the current line. The label will be to the left of the field, and be right-justified. The field will "grow" horizontally as space allows. |
GridBagLayoutBuilder |
appendLabeledField(String propertyName,
JComponent field,
LabelOrientation labelOrientation)
Appends a label and field to the end of the current line. |
GridBagLayoutBuilder |
appendLabeledField(String propertyName,
JComponent field,
LabelOrientation labelOrientation,
int colSpan)
Appends a label and field to the end of the current line. |
GridBagLayoutBuilder |
appendLabeledField(String propertyName,
JComponent field,
LabelOrientation labelOrientation,
int colSpan,
int rowSpan,
boolean expandX,
boolean expandY)
Appends a label and field to the end of the current line. The label will be to the left of the field, and be right-justified. The field will "grow" horizontally as space allows. |
GridBagLayoutBuilder |
appendLeftLabel(String labelKey)
Appends a left-justified label to the end of the given line, using the provided string as the key to look in the ComponentFactory's message
bundle for the text to use. |
GridBagLayoutBuilder |
appendLeftLabel(String labelKey,
int colSpan)
Appends a left-justified label to the end of the given line, using the provided string as the key to look in the ComponentFactory's message
bundle for the text to use. |
GridBagLayoutBuilder |
appendRightLabel(String labelKey)
Appends a right-justified label to the end of the given line, using the provided string as the key to look in the ComponentFactory's message
bundle for the text to use. |
GridBagLayoutBuilder |
appendRightLabel(String labelKey,
int colSpan)
Appends a right-justified label to the end of the given line, using the provided string as the key to look in the ComponentFactory's message
bundle for the text to use. |
GridBagLayoutBuilder |
appendSeparator()
Appends a seperator (usually a horizonal line). |
GridBagLayoutBuilder |
appendSeparator(String labelKey)
Appends a seperator (usually a horizonal line) using the provided string as the key to look in the ComponentFactory's message
bundle for the text to put along with the seperator. |
protected JLabel |
createLabel(String propertyName)
|
ComponentFactory |
getComponentFactory()
|
int |
getCurrentCol()
Returns the current column (zero-based) that the builder is putting components in |
int |
getCurrentRow()
Returns the current row (zero-based) that the builder is putting components in |
Insets |
getDefaultInsets()
Returns the default Insets used when adding components |
JPanel |
getPanel()
Creates and returns a JPanel with all the given components in it, using the "hints" that were provided to the builder. |
GridBagLayoutBuilder |
nextLine()
Ends the current line and starts a new one |
void |
setAutoSpanLastComponent(boolean autoSpanLastComponent)
Should the last column before a nextLine() automaticly span to
the end of the panel?
For example, if you have |
void |
setComponentFactory(ComponentFactory componentFactory)
|
void |
setDefaultInsets(Insets defaultInsets)
Sets the default Insets used when adding components |
void |
setShowGuidelines(boolean showGuidelines)
Should this show "guidelines"? Useful for debugging layouts. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public GridBagLayoutBuilder()
Method Detail |
---|
public Insets getDefaultInsets()
Insets
used when adding components
public void setDefaultInsets(Insets defaultInsets)
Insets
used when adding components
public int getCurrentRow()
public int getCurrentCol()
public ComponentFactory getComponentFactory()
public void setComponentFactory(ComponentFactory componentFactory)
public GridBagLayoutBuilder append(Component component)
component
- the component to add to the current line
public GridBagLayoutBuilder append(Component component, int colSpan, int rowSpan)
component
- the component to add to the current linecolSpan
- the number of columns to spanrowSpan
- the number of rows to span
public GridBagLayoutBuilder append(Component component, int colSpan, int rowSpan, boolean expandX, boolean expandY)
component
- the component to add to the current linecolSpan
- the number of columns to spanrowSpan
- the number of rows to spanexpandX
- should the component "grow" horrizontally?expandY
- should the component "grow" vertically?
public GridBagLayoutBuilder append(Component component, int colSpan, int rowSpan, boolean expandX, boolean expandY, Insets insets)
component
- the component to add to the current linecolSpan
- the number of columns to spanrowSpan
- the number of rows to spanexpandX
- should the component "grow" horrizontally?expandY
- should the component "grow" vertically?insets
- the insets to use for this component
public GridBagLayoutBuilder append(Component component, int x, int y, int colSpan, int rowSpan, boolean expandX, boolean expandY, Insets insets)
component
- the component to add to the current linex
- the column to put the componenty
- the row to put the componentcolSpan
- the number of columns to spanrowSpan
- the number of rows to spanexpandX
- should the component "grow" horrizontally?expandY
- should the component "grow" vertically?insets
- the insets to use for this component
public GridBagLayoutBuilder append(Component component, int colSpan, int rowSpan, double xweight, double yweight)
component
- the component to add to the current linecolSpan
- the number of columns to spanrowSpan
- the number of rows to spanxweight
- the "growth weight" horrizontallyyweight
- the "growth weight" horrizontally
GridBagConstraints.weightx
,
GridBagConstraints.weighty
public GridBagLayoutBuilder append(Component component, int colSpan, int rowSpan, double xweight, double yweight, Insets insets)
component
- the component to add to the current linecolSpan
- the number of columns to spanrowSpan
- the number of rows to spanxweight
- the "growth weight" horrizontallyyweight
- the "growth weight" horrizontallyinsets
- the insets to use for this component
GridBagConstraints.weightx
,
GridBagConstraints.weighty
public GridBagLayoutBuilder appendLabeledField(String propertyName, JComponent field, LabelOrientation labelOrientation)
propertyName
- the name of the property to create the controls for
public GridBagLayoutBuilder appendLabeledField(String propertyName, JComponent field, LabelOrientation labelOrientation, int colSpan)
propertyName
- the name of the property to create the controls forcolSpan
- the number of columns the field should span
public GridBagLayoutBuilder appendLabeledField(String propertyName, JComponent field, LabelOrientation labelOrientation, int colSpan, int rowSpan, boolean expandX, boolean expandY)
propertyName
- the name of the property to create the controls forcolSpan
- the number of columns the field should span
protected JLabel createLabel(String propertyName)
public GridBagLayoutBuilder appendLabeledField(JLabel label, JComponent field, LabelOrientation labelOrientation, int colSpan, int rowSpan, boolean expandX, boolean expandY)
label
- the label to associate and layout with the fieldcolSpan
- the number of columns the field should span
public GridBagLayoutBuilder append(Component component, int x, int y, int colSpan, int rowSpan, double xweight, double yweight, Insets insets)
component
- the component to add to the current linex
- the column to put the componenty
- the row to put the componentcolSpan
- the number of columns to spanrowSpan
- the number of rows to spanxweight
- the "growth weight" horrizontallyyweight
- the "growth weight" horrizontallyinsets
- the insets to use for this component
GridBagConstraints.weightx
,
GridBagConstraints.weighty
public GridBagLayoutBuilder appendLabel(JLabel label)
label
- the label to append
public GridBagLayoutBuilder appendLabel(JLabel label, int colSpan)
label
- the label to appendcolSpan
- the number of columns to span
public GridBagLayoutBuilder appendRightLabel(String labelKey)
ComponentFactory's
message
bundle for the text to use.
labelKey
- the key into the message bundle; if not found the key is used
as the text to display
public GridBagLayoutBuilder appendRightLabel(String labelKey, int colSpan)
ComponentFactory's
message
bundle for the text to use.
labelKey
- the key into the message bundle; if not found the key is used
as the text to displaycolSpan
- the number of columns to span
public GridBagLayoutBuilder appendLeftLabel(String labelKey)
ComponentFactory's
message
bundle for the text to use.
labelKey
- the key into the message bundle; if not found the key is used
as the text to display
public GridBagLayoutBuilder appendLeftLabel(String labelKey, int colSpan)
ComponentFactory's
message
bundle for the text to use.
labelKey
- the key into the message bundle; if not found the key is used
as the text to displaycolSpan
- the number of columns to span
public GridBagLayoutBuilder appendField(Component component)
component
- the item to append
public GridBagLayoutBuilder appendField(Component component, int colSpan)
component
- the item to appendcolSpan
- the number of columns to span
public GridBagLayoutBuilder appendSeparator()
nextLine()
before and after it.
public GridBagLayoutBuilder appendSeparator(String labelKey)
ComponentFactory's
message
bundle for the text to put along with the seperator. Has an implicit
nextLine()
before and after it.
public GridBagLayoutBuilder nextLine()
public void setShowGuidelines(boolean showGuidelines)
public JPanel getPanel()
getPanel
in interface LayoutBuilder
public void setAutoSpanLastComponent(boolean autoSpanLastComponent)
nextLine()
automaticly span to
the end of the panel?
For example, if you have
append(a).append(b).append(c).nextLine(); append(d).append(e).nextLine();then "e" would automaticly span two columns.
autoSpanLastComponent
- default is true
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |