org.wings
Class SBoxLayout

java.lang.Object
  extended by org.wings.SAbstractLayoutManager
      extended by org.wings.SBoxLayout
All Implemented Interfaces:
Serializable, Renderable, SConstants, SLayoutManager

public class SBoxLayout
extends SAbstractLayoutManager

Allows multiple components to be laid out either vertically or horizontally.

Nesting multiple panels with different combinations of horizontal and vertical gives an effect similar to GridBagLayout, without the complexity.

Author:
Holger Engels
See Also:
Serialized Form

Field Summary
protected  int align
           
protected  int borderThickness
           
protected  ArrayList components
           
protected  int hgap
          The horizontal gap (in pixels) specifiying the space between columns.
protected  int orientation
           
protected  int vgap
          The vertical gap (in pixels) which specifiying the space between rows.
static int X_AXIS
           
static int Y_AXIS
           
 
Fields inherited from class org.wings.SAbstractLayoutManager
border, cg, container, preferredSize
 
Fields inherited from interface org.wings.SConstants
BASELINE, BLOCK_ALIGN, BOTTOM, BOTTOM_ALIGN, CENTER, CENTER_ALIGN, HORIZONTAL, JUSTIFY, LEFT, LEFT_ALIGN, NO_ALIGN, RIGHT, RIGHT_ALIGN, TOP, TOP_ALIGN, UID_DIVIDER, VERTICAL
 
Constructor Summary
SBoxLayout(int orientation)
          Deprecated. This constructor mismatch the swing api. Better use SBoxLayout( SContainer c, int orientation )
SBoxLayout(SContainer c, int orientation)
          creates a new box layout with the given orientation
 
Method Summary
 void addComponent(SComponent c, Object constraint, int index)
          Adds a component to the layout manager
 int getBorder()
          Typical PLAFs will render this layout as invisible table (border = 0).
 SComponent getComponentAt(int i)
          returns the component at the given position
 List getComponents()
          returns a list of all components
 int getHgap()
          Gets the horizontal gap between components in pixel.
 int getOrientation()
          returns the orientation
 int getVgap()
          Gets the vertical gap between components in pixel.
 void removeComponent(SComponent c)
          Removes a component from the layout manager
 void setBorder(int borderThickness)
          Typical PLAFs will render this layout as invisible table (border = 0).
 void setHgap(int hgap)
          Sets the horizontal gap between components to the specified value in pixe.
 void setOrientation(int o)
          Sets the orientation.
 void setVgap(int vgap)
          Sets the vertical gap between components to the specified value in pixel.
 
Methods inherited from class org.wings.SAbstractLayoutManager
getCG, getContainer, getPreferredSize, setCG, setContainer, setPreferredSize, updateCG, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

X_AXIS

public static final int X_AXIS
See Also:
Constant Field Values

Y_AXIS

public static final int Y_AXIS
See Also:
Constant Field Values

components

protected ArrayList components

orientation

protected int orientation

align

protected int align

borderThickness

protected int borderThickness

hgap

protected int hgap
The horizontal gap (in pixels) specifiying the space between columns. They can be changed at any time. This should be a non-negative integer.


vgap

protected int vgap
The vertical gap (in pixels) which specifiying the space between rows. They can be changed at any time. This should be a non negative integer.

Constructor Detail

SBoxLayout

public SBoxLayout(int orientation)
Deprecated. This constructor mismatch the swing api. Better use SBoxLayout( SContainer c, int orientation )

creates a new box layout with the given orientation

Parameters:
orientation - either SConstants#VERTICAL or SConstants#HORIZONTAL

SBoxLayout

public SBoxLayout(SContainer c,
                  int orientation)
creates a new box layout with the given orientation

Parameters:
c - - the container that needs to be laid out
orientation - either SConstants#VERTICAL or SConstants#HORIZONTAL
Method Detail

addComponent

public void addComponent(SComponent c,
                         Object constraint,
                         int index)
Description copied from interface: SLayoutManager
Adds a component to the layout manager

Parameters:
c - The new component
constraint - A (sometimes optional) constraint object

removeComponent

public void removeComponent(SComponent c)
Description copied from interface: SLayoutManager
Removes a component from the layout manager

Parameters:
c - The new component

getComponents

public List getComponents()
returns a list of all components

Returns:
all components

getComponentAt

public SComponent getComponentAt(int i)
returns the component at the given position

Parameters:
i - position
Returns:
component

setOrientation

public void setOrientation(int o)
Sets the orientation. Use one of the following types:

Parameters:
o - One of the following constants: SConstants#HORIZONTAL or SConstants#VERTICAL

getOrientation

public int getOrientation()
returns the orientation

Returns:
orientation

setBorder

public void setBorder(int borderThickness)
Typical PLAFs will render this layout as invisible table (border = 0). Use this property to make it visible

Specified by:
setBorder in interface SLayoutManager
Overrides:
setBorder in class SAbstractLayoutManager
Parameters:
borderThickness - The rendered border with in pixel

getBorder

public int getBorder()
Typical PLAFs will render this layout as invisible table (border = 0). Use this property to make it visible

Specified by:
getBorder in interface SLayoutManager
Overrides:
getBorder in class SAbstractLayoutManager
Returns:
The rendered border with in pixel

getHgap

public int getHgap()
Gets the horizontal gap between components in pixel. Rendered half as margin left and margin right Some PLAFs might ignore this property.

Returns:
the horizontal gap between components

setHgap

public void setHgap(int hgap)
Sets the horizontal gap between components to the specified value in pixe. Rendered half as margin left and margin right Some PLAFs might ignore this property.

Parameters:
hgap - the horizontal gap between components

getVgap

public int getVgap()
Gets the vertical gap between components in pixel. Rendered half as margin top and margin bottom Some PLAFs might ignore this property.

Returns:
the vertical gap between components

setVgap

public void setVgap(int vgap)
Sets the vertical gap between components to the specified value in pixel. Rendered half as margin top and margin bottom. Some PLAFs might ignore this property.

Parameters:
vgap - the vertical gap between components


wingS Swings ;-)