Package net.sf.jguiraffe.gui.layout
Klasse ButtonLayout
java.lang.Object
net.sf.jguiraffe.gui.layout.PercentLayoutBase
net.sf.jguiraffe.gui.layout.ButtonLayout
- Alle implementierten Schnittstellen:
Serializable
A layout manager that deals with button bars for dialogs.
With this layout manager typical horizontal button bars for dialogs can be created in an easy way. The button objects simply need to be added to the container, no constraints need to be passed. These button bars have the following properties:
- All buttons have the same width. This is the width of the widest button.
- Between the buttons there is a gap, which can be configured.
- Margins can be defined for all directions. All margins and the gap between the buttons can be defined in several units.
- The alignment of the buttons can be defined. This can be left aligned (i.e. the right margin grows if more space is available in the dialog), right aligned (the left margins grows) or center aligned (both margins grow).
This class is a special implementation of PercentLayoutBase
. It
implements the button layout on top of a percent layout. As its ancestor this
class is platform neutral, i.e. it can work together with different GUI
libraries for which a PercentLayoutPlatformAdapter
implementation is
available.
- Version:
- $Id: ButtonLayout.java 205 2012-01-29 18:29:57Z oheger $
- Autor:
- Oliver Heger
- Siehe auch:
-
Verschachtelte Klassen - Übersicht
Verschachtelte KlassenModifizierer und TypKlasseBeschreibungstatic enum
An enumeration class for the alignment of aButtonLayout
. -
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungReturns the alignment of the button bar.Returns the bottom margin.getGap()
Returns the width of the gap between the buttons.Returns the left margin.Returns the right margin.Returns the top margin.protected void
initCells
(PercentLayoutPlatformAdapter adapter) Initializes the whole layout.protected void
initColumnConstraints
(int lastIndex, int buttonCount) Initializes the column constraints.protected void
Initializes the row constraints.protected void
insertButtons
(PercentLayoutPlatformAdapter adapter, int buttonCount) Inserts all buttons into the percent layout.void
setAlignment
(ButtonLayout.Alignment alignment) Sets the alignment of the button bar.void
setBottomMargin
(NumberWithUnit bottomMargin) Sets the bottom margin.void
setGap
(NumberWithUnit gap) Sets the width of the gap between the buttons.void
setLeftMargin
(NumberWithUnit leftMargin) Sets the left margin.void
setRightMargin
(NumberWithUnit rightMargin) Sets the right margin.void
setTopMargin
(NumberWithUnit topMargin) Sets the top margin.Von Klasse geerbte Methoden net.sf.jguiraffe.gui.layout.PercentLayoutBase
addColumnGroup, addRowGroup, alignComponent, applyCellGroups, applyWeightFactors, applyWeightFactors, calcCellPositions, calcCellSize, calcCellSizes, calcCellSizesWithGroups, calcComponentSize, calcComponentSizes, calcMinimumLayoutSize, calcPreferredLayoutSize, calcSizes, calcTotalWeight, checkConstraints, clearCells, clearCells, constraintsFor, fetchPlatformAdapter, flushCache, getAllColumnConstraints, getAllRowConstraints, getColumnConstraints, getColumnCount, getColumnGroups, getComponent, getConstraintsBuilder, getInternalAllColumnConstraints, getInternalAllRowConstraints, getMinimumComponentSize, getOrientationValue, getPercentData, getPlatformAdapter, getPreferredComponentSize, getRowConstraints, getRowCount, getRowGroups, getSizeHandler, getTotalWeightX, getTotalWeightY, handleMultiSpans, initCell, initDimensions, initFromCollections, isCanShrink, performLayout, performLayout, removeComponent, setCanShrink, setColumnConstraints, setComponentBounds, setPlatformAdapter, setRowConstraints
-
Konstruktordetails
-
ButtonLayout
public ButtonLayout()Creates a new instance ofButtonLayout
. All properties are set to default values.
-
-
Methodendetails
-
getTopMargin
Returns the top margin.- Gibt zurück:
- the top margin
-
setTopMargin
Sets the top margin. This is the space above the buttons.- Parameter:
topMargin
- the top margin (a null reference is converted to a value of 0)
-
getBottomMargin
Returns the bottom margin.- Gibt zurück:
- the bottom margin
-
setBottomMargin
Sets the bottom margin. This is the space below the buttons.- Parameter:
bottomMargin
- the bottom margin
-
getLeftMargin
Returns the left margin.- Gibt zurück:
- the left margin
-
setLeftMargin
Sets the left margin. This is the space between the window's left edge and the first button. This value is fixed only if the button bar is left aligned; otherwise this space may grow.- Parameter:
leftMargin
- the left margin (a null reference is converted to a value of 0)
-
getRightMargin
Returns the right margin.- Gibt zurück:
- the right margin
-
setRightMargin
Sets the right margin. This is the space between the window's right edge and the last button. This value is fixed only if the button bar is right aligned; otherwise this space may grow.- Parameter:
rightMargin
- the right margin (a null reference is converted to a value of 0)
-
getGap
Returns the width of the gap between the buttons.- Gibt zurück:
- the gap
-
setGap
Sets the width of the gap between the buttons.- Parameter:
gap
- the gap's width (a null reference is converted to a value of 0)
-
getAlignment
Returns the alignment of the button bar.- Gibt zurück:
- the alignment
-
setAlignment
Sets the alignment of the button bar.- Parameter:
alignment
- the new alignment (must not be null)- Löst aus:
IllegalArgumentException
- if the alignment is null
-
initCells
Initializes the whole layout. Creates a percent layout based on the current property values and the contained buttons.- Angegeben von:
initCells
in KlassePercentLayoutBase
- Parameter:
adapter
- the currently used platform adapter
-
initRowConstraints
protected void initRowConstraints()Initializes the row constraints. -
initColumnConstraints
protected void initColumnConstraints(int lastIndex, int buttonCount) Initializes the column constraints.- Parameter:
lastIndex
- the index of the last columnbuttonCount
- the number of buttons
-
insertButtons
Inserts all buttons into the percent layout.- Parameter:
adapter
- the platform adapterbuttonCount
- the number of available buttons
-