|
Xj3D 2.0 VRML/X3D Code API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.xj3d.ui.awt.widgets.DynamicGridLayout
public class DynamicGridLayout
A layout manager that lays out a container's components in a rectangular grid, with different sizes for each row/column.
As with GridLayout one component is placed in each rectangle, but the width of columns and height of rows are not necessarily the same. By default each row and column will be sized in proportion to the minimum size of the largest component in that row or column. Alternatively, individual rows or columns can be set to a fixed percentage of the container or their minimum size with various options. Components can also be set to fill the assigned area or use their minimum size and align themselves within that allocated space. If the grid itself doesn't completely fill the area assigned by the container there are methods to set this alignment too.
Here's a simple example of using a DynamicGridLayout.
//create the layout and set it
setLayout(dgl=new DynamicGridLayout(2,2,5,5));
//set any styles, sizes or alignments
dgl.setRowSize(0,dgl.MINIMUM);
//add the components
add(new Button("Row One/Col One"));
add(new Button("Row One/Col Two"));
add(new Button("Row Two/Col One"));
add(new Button("Row Two/Col Two"));
| Field Summary | |
|---|---|
static int |
ABOVE_MINIMUM
|
static int |
BELOW_MINIMUM
|
static int |
BOTTOM
|
static int |
CENTER
|
static int |
DYNAMIC
|
static int |
FILL
|
static int |
LABEL_FILL
|
static int |
LABEL_MIN
|
static int |
LEFT
|
static int |
MINIMUM
|
static int |
RIGHT
|
static int |
TOP
|
| Constructor Summary | |
|---|---|
DynamicGridLayout()
Creates a grid layout with a default of one column per component, in a single row. |
|
DynamicGridLayout(int rows,
int cols)
Creates a grid layout with the specified number of rows and columns. |
|
DynamicGridLayout(int rows,
int cols,
int hgap,
int vgap)
Creates a grid layout with the specified number of rows and columns. |
|
| Method Summary | |
|---|---|
void |
addLayoutComponent(java.lang.String name,
java.awt.Component comp)
Adds the specified component with the specified name to the layout. |
int |
getColumns()
Gets the number of columns in this layout. |
int |
getHgap()
Gets the horizontal gap between components. |
int |
getRows()
Gets the number of rows in this layout. |
int |
getVgap()
Gets the vertical gap between components. |
void |
layoutContainer(java.awt.Container parent)
Lays out the specified container using this layout. |
java.awt.Dimension |
minimumLayoutSize(java.awt.Container parent)
Determines the minimum size of the container argument using this grid layout. |
java.awt.Dimension |
preferredLayoutSize(java.awt.Container parent)
Determines the preferred size of the container argument using this grid layout. |
void |
removeLayoutComponent(java.awt.Component comp)
Removes the specified component from the layout. |
void |
resetGrid()
Resets the grid parameters. |
void |
setColumnAlignment(int col,
int value)
Sets the alignment for a particular column. |
void |
setColumnAlignments(int start,
int end,
int value)
Sets the alignment of multiple columns. |
void |
setColumns(int cols)
Sets the number of columns in this layout to the specified value. |
void |
setColumnSize(int col,
int value)
Sets the size of a column. |
void |
setColumnSizes(int start,
int end,
int value)
Sets the size of multiple columns. |
void |
setHgap(int hgap)
Sets the horizontal gap between components to the specified value. |
void |
setHorizontalAlignment(int value)
This method is only required if there are no columns with dynamic widths which may cause the layout to be smaller than the allocated space. |
void |
setRowAlignment(int row,
int value)
Sets the alignment for a particular row. |
void |
setRowAlignments(int start,
int end,
int value)
Sets the alignment of multiple rows. |
void |
setRows(int rows)
Sets the number of rows in this layout to the specified value. |
void |
setRowSize(int row,
int value)
Sets the size of a row. |
void |
setRowSizes(int start,
int end,
int value)
Sets the size of multiple rows. |
void |
setStyle(int style)
Sets the style of this grid. |
void |
setVerticalAlignment(int value)
This method is only required if there are no rows with dynamic heights which may cause the layout to be smaller than the allocated space. |
void |
setVgap(int vgap)
Sets the vertical gap between components to the specified value. |
java.lang.String |
toString()
Returns the string representation of this grid layout's values. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int DYNAMIC
public static final int MINIMUM
public static final int ABOVE_MINIMUM
public static final int BELOW_MINIMUM
public static final int FILL
public static final int CENTER
public static final int LEFT
public static final int RIGHT
public static final int TOP
public static final int BOTTOM
public static final int LABEL_FILL
public static final int LABEL_MIN
| Constructor Detail |
|---|
public DynamicGridLayout()
public DynamicGridLayout(int rows,
int cols)
One, but not both, of rows and cols can
be zero, which means that any number of objects can be placed in a
row or in a column.
rows - the rows, with the value zero meaning
any number of rows.cols - the columns, with the value zero meaning
any number of columns.
public DynamicGridLayout(int rows,
int cols,
int hgap,
int vgap)
In addition, the horizontal and vertical gaps are set to the specified values. Horizontal gaps are placed at the left and right edges, and between each of the columns. Vertical gaps are placed at the top and bottom edges, and between each of the rows.
One, but not both, of rows and cols can
be zero, which means that any number of objects can be placed in a
row or in a column.
rows - the rows, with the value zero meaning
any number of rows.cols - the columns, with the value zero meaning
any number of columns.hgap - the horizontal gap.vgap - the vertical gap.
java.lang.IllegalArgumentException - if the of rows
or cols is invalid.| Method Detail |
|---|
public int getRows()
public void setRows(int rows)
rows - the number of rows in this layout.
java.lang.IllegalArgumentException - if the value of both
rows and cols is set to zero.public int getColumns()
public void setColumns(int cols)
cols - the number of columns in this layout.
java.lang.IllegalArgumentException - if the value of both
rows and cols is set to zero.public int getHgap()
public void setHgap(int hgap)
hgap - the horizontal gap between components.public int getVgap()
public void setVgap(int vgap)
vgap - the vertical gap between components.public void resetGrid()
public void setStyle(int style)
The style parameter has the following parameters:
style - The style to be set.public void setHorizontalAlignment(int value)
value - the alignment to setpublic void setVerticalAlignment(int value)
value - the alignment to set
public void setRowAlignment(int row,
int value)
row - The row to set the alignment forvalue - The alignment to set.
public void setRowAlignments(int start,
int end,
int value)
start - the inclusive start row to setend - the inclusive end row to setvalue - the alignment to setsetRowAlignment(int, int)
public void setColumnAlignment(int col,
int value)
col - The column to set the alignment forvalue - The alignment to set.
public void setColumnAlignments(int start,
int end,
int value)
start - The inclusive start column to setend - The inclusive end column to setvalue - The alignment to setsetColumnAlignment(int, int)
public void setRowSize(int row,
int value)
public void setRowSizes(int start,
int end,
int value)
start - The inclusive start row to setend - The inclusive end row to setvalue - The size to setsetRowSize(int, int)
public void setColumnSize(int col,
int value)
public void setColumnSizes(int start,
int end,
int value)
start - The inclusive start column to setend - The inclusive end column to setvalue - The size to setsetColumnSize(int, int)
public void addLayoutComponent(java.lang.String name,
java.awt.Component comp)
addLayoutComponent in interface java.awt.LayoutManagername - the name of the component.comp - the component to be added.public void removeLayoutComponent(java.awt.Component comp)
removeLayoutComponent in interface java.awt.LayoutManagercomp - the component to be removed.public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
The preferred width of a grid layout is the largest preferred width of any of the widths in the container times the number of columns, plus the horizontal padding times the number of columns plus one, plus the left and right insets of the target container.
The preferred height of a grid layout is the largest preferred height of any of the heights in the container times the number of rows, plus the vertical padding times the number of rows plus one, plus the top and bottom insets of the target container.
preferredLayoutSize in interface java.awt.LayoutManagerparent - the container in which to do the layout.
GridLayout.minimumLayoutSize(java.awt.Container),
Container.getPreferredSize()public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
The minimum width of a grid layout is the largest minimum width of any of the widths in the container times the number of columns, plus the horizontal padding times the number of columns plus one, plus the left and right insets of the target container.
The minimum height of a grid layout is the largest minimum height of any of the heights in the container times the number of rows, plus the vertical padding times the number of rows plus one, plus the top and bottom insets of the target container.
minimumLayoutSize in interface java.awt.LayoutManagerparent - the container in which to do the layout.
GridLayout.preferredLayoutSize(java.awt.Container),
Container.doLayout()public void layoutContainer(java.awt.Container parent)
This method reshapes the components in the specified target
container in order to satisfy the constraints of the
GridLayout object.
The grid layout manager determines the size of individual components by dividing the free space in the container into equal-sized portions according to the number of rows and columns in the layout. The container's free space equals the container's size minus any insets and any specified horizontal or vertical gap. All components in a grid layout are given the same size.
layoutContainer in interface java.awt.LayoutManagerparent - the container in which to do the layout.Container,
Container.doLayout()public java.lang.String toString()
toString in class java.lang.Object
|
Xj3D 2.0 VRML/X3D Code API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||