GridContainer is a WidgetContainer which arranges its child Widgets in a uniform grid. Every column is
the same width, and every row is the same height.
In addition to the event types generated by all Widgets, GridContainers generate the following event types:
add
public void add(Widget widget,
int col,
int row)
Add a Widget to this container, using the default LayoutInfo to position it. If there is already
a Widget in the specified cell, that one will be removed before the new one is added.
widget
- the Widget to addcol
- the column in which to place the Widgetrow
- the row in which to place the Widget
add
public void add(Widget widget,
int col,
int row,
LayoutInfo layout)
Add a Widget to this container. If there is already a Widget in the specified cell, that one will
be removed before the new one is added.
widget
- the Widget to addcol
- the column in which to place the Widgetrow
- the row in which to place the Widgetlayout
- the LayoutInfo to use for this Widget. If null, the default LayoutInfo will be used.
getChild
public Widget getChild(int col,
int row)
Get the child in a particular cell.
col
- the column for which to get the Widgetrow
- the row for which to get the Widget
- the Widget in the specified cell
getChildCell
public Point getChildCell(Widget widget)
Get the cell containing the specified Widget.
widget
- the Widget to locate
- a Point containing the row and column where the Widget is located, or null if the Widget is
not a child of the container
getChildLayout
public LayoutInfo getChildLayout(Widget widget)
Get the LayoutInfo for a particular Widget.
widget
- the Widget for which to get the LayoutInfo
- the LayoutInfo being used for that Widget. This may return null, which indicates that the
default LayoutInfo is being used. It will also return null if the specified Widget is not
a child of this container.
getChildLayout
public LayoutInfo getChildLayout(int col,
int row)
Get the LayoutInfo for the Widget in a particular cell.
col
- the column of the Widget for which to get the LayoutInforow
- the row of the Widget for which to get the LayoutInfo
- the LayoutInfo being used for that cell. This may return null, which indicates that the
default LayoutInfo is being used.
getColumnCount
public int getColumnCount()
Get the number of columns in the grid.
getDefaultLayout
public LayoutInfo getDefaultLayout()
Get the default LayoutInfo.
getMinimumSize
public Dimension getMinimumSize()
Get the smallest size at which this Widget can reasonably be drawn. When a WidgetContainer lays out
its contents, it will attempt never to make this Widget smaller than its minimum size.
- getMinimumSize in interface Widget
getPreferredSize
public Dimension getPreferredSize()
Get the preferred size at which this Widget will look best. When a WidgetContainer lays out
its contents, it will attempt to make this Widget as close as possible to its preferred size.
- getPreferredSize in interface Widget
getRowCount
public int getRowCount()
Get the number of rows in the grid.
layoutChildren
public void layoutChildren()
Layout the child Widgets. This may be invoked whenever something has changed (the size of this
WidgetContainer, the preferred size of one of its children, etc.) that causes the layout to no
longer be correct. If a child is itself a WidgetContainer, its layoutChildren() method will be
called in turn.
- layoutChildren in interface WidgetContainer
remove
public void remove(Widget widget)
Remove a child Widget from this container.
- remove in interface WidgetContainer
widget
- the Widget to remove
remove
public void remove(int col,
int row)
Remove the Widget in a particular cell from this container.
col
- the column from which to remove the Widgetrow
- the row from which to remove the Widget
setChildLayout
public void setChildLayout(Widget widget,
LayoutInfo layout)
Set the LayoutInfo for a particular Widget.
widget
- the Widget for which to set the LayoutInfolayout
- the new LayoutInfo. If null, the default LayoutInfo will be used
setChildLayout
public void setChildLayout(int col,
int row,
LayoutInfo layout)
Set the LayoutInfo for the Widget in a particular cell.
col
- the column of the Widget for which to set the LayoutInforow
- the row of the Widget for which to set the LayoutInfolayout
- the new LayoutInfo. If null, the default LayoutInfo will be used
setColumnCount
public void setColumnCount(int cols)
Set the number of columns in the grid. If this causes the grid to shrink, all Widgets which do not fit
into the new grid will be removed.
setDefaultLayout
public void setDefaultLayout(LayoutInfo layout)
Set the default LayoutInfo.
setRowCount
public void setRowCount(int rows)
Set the number of rows in the grid. If this causes the grid to shrink, all Widgets which do not fit
into the new grid will be removed.