org.zaval.lw
Class LwBorderLayout

java.lang.Object
  |
  +--org.zaval.lw.LwBorderLayout
All Implemented Interfaces:
LwLayout

public class LwBorderLayout
extends java.lang.Object
implements LwLayout

The class implements layout manager interface. The layout divides container area into five parts: North, South, East, West, and Center. To add a component to a container with the border layout, use one of constants of this layout manager as the constraints, for example:

    ...
    LwContainer c = new LwPanel();
    c.setLwLayout(new LwBorderLayout());
    c.add(LwBorderLayout.SOUTH, new LwButton("South"));
    ...
 
The image below shows how the five buttons have been laid out with the border layout manager inside the container:


Actually the light weight border layout manager is the same of java.awt.BorderLayout.


Field Summary
static java.lang.Object CENTER
          The center layout constraint (middle of container).
static java.lang.Object EAST
          The east layout constraint (left side of container).
static java.lang.Object NORTH
          The north layout constraint (top of container).
static java.lang.Object SOUTH
          The south layout constraint (bottom of container).
static java.lang.Object WEST
          The west layout constraint (right side of container).
 
Constructor Summary
LwBorderLayout()
          Constructs a new border layout with no gaps between components.
LwBorderLayout(int hgap, int vgap)
          Constructs a border layout with the specified gaps between components.
 
Method Summary
 java.awt.Dimension calcPreferredSize(LayoutContainer target)
          Calculates the preferred size dimension for the layout container.
 void componentAdded(java.lang.Object id, Layoutable comp, int index)
          Invoked when the specified layoutable component is added to the layout container, that uses the layout manager.
 void componentRemoved(Layoutable lw, int index)
          Invoked when the specified layoutable component is removed from the layout container, that uses the layout manager.
 int getHgap()
          Returns the horizontal.
 int getVgap()
          Returns the vertical gap.
protected static boolean isVisible(Layoutable l)
          Tests if the specified layout container is not null and visible.
 void layout(LayoutContainer target)
          Lays out the child layoutable components inside the specified layout container.
 void setHgap(int hgap)
          Sets the horizontal gap.
 void setVgap(int vgap)
          Sets the vertical gap.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NORTH

public static final java.lang.Object NORTH
The north layout constraint (top of container).

SOUTH

public static final java.lang.Object SOUTH
The south layout constraint (bottom of container).

EAST

public static final java.lang.Object EAST
The east layout constraint (left side of container).

WEST

public static final java.lang.Object WEST
The west layout constraint (right side of container).

CENTER

public static final java.lang.Object CENTER
The center layout constraint (middle of container).
Constructor Detail

LwBorderLayout

public LwBorderLayout()
Constructs a new border layout with no gaps between components.

LwBorderLayout

public LwBorderLayout(int hgap,
                      int vgap)
Constructs a border layout with the specified gaps between components. The horizontal gap is specified by hgap and the vertical gap is specified by vgap.
Parameters:
hgap - the horizontal gap.
vgap - the vertical gap.
Method Detail

getHgap

public int getHgap()
Returns the horizontal.
Returns:
a horizontal gap.

setHgap

public void setHgap(int hgap)
Sets the horizontal gap.
Parameters:
hgap - the horizontal gap.

getVgap

public int getVgap()
Returns the vertical gap.
Returns:
a vertical gap.

setVgap

public void setVgap(int vgap)
Sets the vertical gap.
Parameters:
vgap - the vertical gap.

componentAdded

public void componentAdded(java.lang.Object id,
                           Layoutable comp,
                           int index)
Invoked when the specified layoutable component is added to the layout container, that uses the layout manager. The specified constraints, layoutable component and child index are passed as arguments into the method. For the border layout manager, the constraints must be equal one of the manager constants, otherwise IllegalArgumentException will be performed.
Specified by:
componentAdded in interface LwLayout
Parameters:
id - the layoutable component constraints.
comp - the layoutable component.
index - the child index.

componentRemoved

public void componentRemoved(Layoutable lw,
                             int index)
Invoked when the specified layoutable component is removed from the layout container, that uses the layout manager.
Specified by:
componentRemoved in interface LwLayout
Parameters:
lw - the layoutable component to be removed
index - the child index.

calcPreferredSize

public java.awt.Dimension calcPreferredSize(LayoutContainer target)
Calculates the preferred size dimension for the layout container. The method calculates "pure" preferred size, it means that an insets of the container is not considered as a part of the preferred size.
Specified by:
calcPreferredSize in interface LwLayout
Parameters:
target - the layout container.

layout

public void layout(LayoutContainer target)
Lays out the child layoutable components inside the specified layout container.
Specified by:
layout in interface LwLayout
Parameters:
target - the layout container that needs to be laid out.

isVisible

protected static boolean isVisible(Layoutable l)
Tests if the specified layout container is not null and visible.
Parameters:
l - the specified layout container.
Returns:
true if the layoutable component is not null and visible; otherwise false


Copyright © Zaval Creative Engineering Group, 2000-2005.
http://www.zaval.org