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.ContainerLays 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 voidaddChild(ej.mwt.Widget child)protected voidcomputeContentOptimalSize(ej.mwt.util.Size size)ej.mwt.WidgetgetCellChild(int column, int row)Gets the widget at the specified column and row.intgetCount()Gets the number of widgets per row/column (depending on the grid orientation).booleangetOrientation()Gets the orientation of this grid.voidinsertChild(ej.mwt.Widget child, int index)protected voidlayOutChildren(int contentWidth, int contentHeight)voidremoveAllChildren()voidremoveChild(ej.mwt.Widget child)voidreplaceChild(int index, ej.mwt.Widget child)voidsetCount(int count)Sets the number of widgets per row/column (depending on the grid orientation).voidsetOrientation(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:
addChildin classej.mwt.Container
-
removeChild
public void removeChild(ej.mwt.Widget child)
- Overrides:
removeChildin classej.mwt.Container
-
insertChild
public void insertChild(ej.mwt.Widget child, int index)- Overrides:
insertChildin classej.mwt.Container
-
replaceChild
public void replaceChild(int index, ej.mwt.Widget child)- Overrides:
replaceChildin classej.mwt.Container
-
removeAllChildren
public void removeAllChildren()
- Overrides:
removeAllChildrenin classej.mwt.Container
-
computeContentOptimalSize
protected void computeContentOptimalSize(ej.mwt.util.Size size)
- Specified by:
computeContentOptimalSizein classej.mwt.Widget
-
layOutChildren
protected void layOutChildren(int contentWidth, int contentHeight)- Specified by:
layOutChildrenin classej.mwt.Container
-
-