|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.zaval.lw.LwGridLayout
This class implements layout manager interface. The layout manager divides the container area into certain quantity of virtual rows and columns and every cell is used to place a child component. A column preferred width is calculated as maximal preferred width among all cells of the column. A row preferred height is calculated as maximal preferred height among all cells of the row.
If the virtual cell space is larger than the component preferred size than the additional
constraints can be defined. Use LwConstraints class as the input argument of add
container method to describe the cell constraints. Using the constraints you can define
vertical and horizontal alignments, insets, filling rules. The table below illustrates the
layout manager usage (the samples use grid layout manager with two columns and two rows):
Constraints | Sample App |
Default constraints (fill=LwToolkit.HORIZONTAL|LwToolkit.VERTICAL). | |
Cell[1][1] uses fill=LwToolkit.HORIZONTAL, vertical alignment is LwToolkit.CENTER. | |
Cell[1][1] uses fill=LwToolkit.NONE, vertical alignment is Alignment.CENTER and horizontal alignment is Alignment.CENTER. | |
Cell[1][1] uses fill=LwToolkit.NONE, vertical alignment is Alignment.TOP and horizontal alignment is Alignment.LEFT. | |
Cell[1][1] uses fill=LwToolkit.VERTICAL, horizontal alignment is Alignment.RIGHT. |
Constructor Summary | |
LwGridLayout(int r,
int c)
Constructs a new grid layout with the specified number of rows and columns. |
|
LwGridLayout(int r,
int c,
int m)
Constructs a new grid layout with the specified number of rows, columns and the layout stretching mask. |
Method Summary | |
java.awt.Dimension |
calcPreferredSize(LayoutContainer c)
Calculates the preferred size dimension for the layout container. |
void |
componentAdded(java.lang.Object id,
Layoutable b,
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 |
getLines()
Implements org.zaval.misc.PosInfo interface method to define number of lines. |
int |
getLineSize(int line)
Implements org.zaval.misc.PosInfo interface method to define the line size. |
int |
getMaxOffset()
Implements org.zaval.misc.PosInfo interface method to define max offset. |
void |
layout(LayoutContainer c)
Lays out the child layoutable components inside the layout container. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public LwGridLayout(int r, int c)
r
- the specified number of rows.c
- the specified number of columns.public LwGridLayout(int r, int c, int m)
r
- the specified number of rows.c
- the specified number of columns.m
- the layout stretching mask. The mask indicates if it is necessary to stretch
virtual cells' sizes according to a parent area size. Use LwToolkit.HORIZONTAL, LwToolkit.VERTICAL or
LwToolkit.NONE values to construct the mask value.Method Detail |
public java.awt.Dimension calcPreferredSize(LayoutContainer c)
calcPreferredSize
in interface LwLayout
c
- the layout container.public void layout(LayoutContainer c)
layout
in interface LwLayout
c
- the layout container that needs to be laid out.public void componentAdded(java.lang.Object id, Layoutable b, int index)
componentAdded
in interface LwLayout
id
- the layoutable component constraints.b
- the layoutable component.index
- the child index.public void componentRemoved(Layoutable lw, int index)
componentRemoved
in interface LwLayout
lw
- the layoutable component to be removedindex
- the child index.public int getLines()
getLines
in interface PosInfo
public int getLineSize(int line)
getLineSize
in interface PosInfo
line
- the line number.public int getMaxOffset()
getMaxOffset
in interface PosInfo
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |