Package ej.widget.container
Class Grid
- java.lang.Object
-
- ej.mwt.Widget
-
- ej.mwt.Container
-
- ej.widget.container.Grid
-
public class Grid extends ej.mwt.Container
Lays out any number of children in a grid.All the children are laid out in a grid, which has a fixed number of columns if the grid is horizontal, or a fixed number of rows if the grid is vertical.
In a grid, all children have the same width and the same height, regardless of their optimal size.
Horizontal:
Vertical:
-
-
Constructor Summary
Constructors Constructor Description Grid(boolean orientation, int count)
Creates a grid specifying its orientation and the number of widgets per row/column (depending on the orientation chosen via the horizontal parameter).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addChild(ej.mwt.Widget child)
protected void
computeContentOptimalSize(ej.mwt.util.Size size)
ej.mwt.Widget
getCellChild(int column, int row)
Gets the widget at the specified column and row.int
getCount()
Gets the number of widgets per row/column (depending on the grid orientation).boolean
getOrientation()
Gets the orientation of this grid.void
insertChild(ej.mwt.Widget child, int index)
protected void
layOutChildren(int contentWidth, int contentHeight)
void
removeAllChildren()
void
removeChild(ej.mwt.Widget child)
void
replaceChild(int index, ej.mwt.Widget child)
void
setCount(int count)
Sets the number of widgets per row/column (depending on the grid orientation).void
setOrientation(boolean orientation)
Sets the orientation of this grid.-
Methods inherited from class ej.mwt.Container
changeChildIndex, computeChildOptimalSize, getChild, getChildIndex, getChildren, getChildrenCount, getContentBounds, getContentHeight, getContentWidth, getContentX, getContentY, getWidgetAt, layOutAlignedChild, layOutChild, renderChild, renderContent, setHiddenChild, setHiddenChildren, setShownChild, setShownChildren, updateStyle
-
Methods inherited from class ej.mwt.Widget
addClassSelector, contains, containsWidget, getAbsoluteX, getAbsoluteY, getDesktop, getHeight, getParent, getStyle, getWidth, getX, getY, handleEvent, hasClassSelector, isAttached, isEnabled, isInState, isShown, isTransparent, onAttached, onDetached, onHidden, onLaidOut, onShown, removeAllClassSelectors, removeClassSelector, render, requestLayOut, requestRender, requestRender, setClassSelectors, setEnabled, setPosition, setStyle
-
-
-
-
Constructor Detail
-
Grid
public Grid(boolean orientation, int count)
Creates a grid specifying its orientation and the number of widgets per row/column (depending on the orientation chosen via the horizontal parameter).- Parameters:
orientation
- the orientation of the grid (seeLayoutOrientation
).count
- the number of widgets per row/column to set.- Throws:
java.lang.IllegalArgumentException
- if the count is negative or zero.
-
-
Method Detail
-
setOrientation
public void setOrientation(boolean orientation)
Sets the orientation of this grid.- Parameters:
orientation
- the orientation to set (seeLayoutOrientation
).
-
getOrientation
public boolean getOrientation()
Gets the orientation of this grid.- Returns:
- the orientation of this grid (see
LayoutOrientation
).
-
setCount
public void setCount(int count)
Sets the number of widgets per row/column (depending on the grid orientation).- Parameters:
count
- the number of widgets per row/column to set.- Throws:
java.lang.IllegalArgumentException
- if the count is negative or zero.
-
getCount
public int getCount()
Gets the number of widgets per row/column (depending on the grid orientation).- Returns:
- the number of widgets per row/column.
-
getCellChild
public ej.mwt.Widget getCellChild(int column, int row)
Gets the widget at the specified column and row.- Parameters:
column
- the column of the widget to return.row
- the row of the widget to return.- Returns:
- the widget at the specified column and row.
- Throws:
java.lang.IndexOutOfBoundsException
- if the cell referenced by the given coordinates is out of range.
-
addChild
public void addChild(ej.mwt.Widget child)
- Overrides:
addChild
in classej.mwt.Container
-
removeChild
public void removeChild(ej.mwt.Widget child)
- Overrides:
removeChild
in classej.mwt.Container
-
insertChild
public void insertChild(ej.mwt.Widget child, int index)
- Overrides:
insertChild
in classej.mwt.Container
-
replaceChild
public void replaceChild(int index, ej.mwt.Widget child)
- Overrides:
replaceChild
in classej.mwt.Container
-
removeAllChildren
public void removeAllChildren()
- Overrides:
removeAllChildren
in classej.mwt.Container
-
computeContentOptimalSize
protected void computeContentOptimalSize(ej.mwt.util.Size size)
- Specified by:
computeContentOptimalSize
in classej.mwt.Widget
-
layOutChildren
protected void layOutChildren(int contentWidth, int contentHeight)
- Specified by:
layOutChildren
in classej.mwt.Container
-
-