Klasse ButtonLayout

java.lang.Object
net.sf.jguiraffe.gui.layout.PercentLayoutBase
net.sf.jguiraffe.gui.layout.ButtonLayout
Alle implementierten Schnittstellen:
Serializable

public class ButtonLayout extends PercentLayoutBase

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:
  • Konstruktordetails

    • ButtonLayout

      public ButtonLayout()
      Creates a new instance of ButtonLayout. All properties are set to default values.
  • Methodendetails

    • getTopMargin

      public NumberWithUnit getTopMargin()
      Returns the top margin.
      Gibt zurück:
      the top margin
    • setTopMargin

      public void setTopMargin(NumberWithUnit topMargin)
      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

      public NumberWithUnit getBottomMargin()
      Returns the bottom margin.
      Gibt zurück:
      the bottom margin
    • setBottomMargin

      public void setBottomMargin(NumberWithUnit bottomMargin)
      Sets the bottom margin. This is the space below the buttons.
      Parameter:
      bottomMargin - the bottom margin
    • getLeftMargin

      public NumberWithUnit getLeftMargin()
      Returns the left margin.
      Gibt zurück:
      the left margin
    • setLeftMargin

      public void setLeftMargin(NumberWithUnit leftMargin)
      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

      public NumberWithUnit getRightMargin()
      Returns the right margin.
      Gibt zurück:
      the right margin
    • setRightMargin

      public void setRightMargin(NumberWithUnit rightMargin)
      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

      public NumberWithUnit getGap()
      Returns the width of the gap between the buttons.
      Gibt zurück:
      the gap
    • setGap

      public void setGap(NumberWithUnit gap)
      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

      public ButtonLayout.Alignment getAlignment()
      Returns the alignment of the button bar.
      Gibt zurück:
      the alignment
    • setAlignment

      public void setAlignment(ButtonLayout.Alignment alignment)
      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

      protected void initCells(PercentLayoutPlatformAdapter adapter)
      Initializes the whole layout. Creates a percent layout based on the current property values and the contained buttons.
      Angegeben von:
      initCells in Klasse PercentLayoutBase
      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 column
      buttonCount - the number of buttons
    • insertButtons

      protected void insertButtons(PercentLayoutPlatformAdapter adapter, int buttonCount)
      Inserts all buttons into the percent layout.
      Parameter:
      adapter - the platform adapter
      buttonCount - the number of available buttons