Class FixedGrid
- java.lang.Object
-
- ej.mwt.Widget
-
- ej.mwt.Container
-
- ej.widget.container.FixedGrid
-
public class FixedGrid extends 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 and rows.
In a grid, all children have the same width and the same height, regardless of their optimal size.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ej.mwt.Widget
Widget.WidgetListener
-
-
Field Summary
-
Fields inherited from class ej.mwt.Widget
DEBUG_WIDGET_ENABLED_CONSTANT, DEBUG_WIDGET_MONITOR_CONSTANT, NO_CONSTRAINT
-
-
Constructor Summary
Constructors Constructor Description FixedGrid(int columns, int rows)Creates a grid specifying its number of columns and rows.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChild(Widget child, int column, int row)Adds a widget at the specified column and row.protected voidcomputeContentOptimalSize(Size size)Computes the optimal size of the widget.WidgetgetCellChild(int column, int row)Gets the widget at the specified column and row.intgetColumns()Gets the number of columns.intgetRows()Gets the number of rows.protected voidlayOutChildren(int contentWidth, int contentHeight)Lays out the children of this container.voidremoveAllChildren()Removes all the children of this container.voidremoveChild(int column, int row)Removes the widget at the specified column and row.-
Methods inherited from class ej.mwt.Container
addChild, changeChildIndex, computeChildOptimalSize, getChild, getChildIndex, getChildren, getChildrenCount, getContentBounds, getContentHeight, getContentWidth, getContentX, getContentY, getWidgetAt, insertChild, layOutAlignedChild, layOutChild, removeChild, renderChild, renderContent, replaceChild, 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, setX, setY
-
-
-
-
Constructor Detail
-
FixedGrid
public FixedGrid(int columns, int rows)Creates a grid specifying its number of columns and rows.- Parameters:
columns- the number of columnsrows- the number of rows- Throws:
IllegalArgumentException- if one of the parameters is negative or zero
-
-
Method Detail
-
getColumns
public int getColumns()
Gets the number of columns.- Returns:
- the number of columns.
-
getRows
public int getRows()
Gets the number of rows.- Returns:
- the number of rows.
-
getCellChild
@Nullable public Widget getCellChild(int column, int row)
Gets the widget at the specified column and row.- Parameters:
column- the column of the widget to returnrow- the row of the widget to return- Returns:
- the widget at the specified column and row
- Throws:
IndexOutOfBoundsException- if the cell referenced by the given coordinates is out of range
-
addChild
public void addChild(Widget child, int column, int row)
Adds a widget at the specified column and row.- Parameters:
child- the child to addcolumn- the column of the widgetrow- the row of the widget- Throws:
IndexOutOfBoundsException- if the cell referenced by the given coordinates is out of range
-
removeChild
public void removeChild(int column, int row)Removes the widget at the specified column and row.- Parameters:
column- the column of the widgetrow- the row of the widget- Throws:
IndexOutOfBoundsException- if the cell referenced by the given coordinates is out of range
-
removeAllChildren
public void removeAllChildren()
Description copied from class:ContainerRemoves all the children of this container.The container needs to be laid out again.
Should be called in the display thread to avoid concurrency issues.
- Overrides:
removeAllChildrenin classContainer- See Also:
Widget.requestLayOut()
-
computeContentOptimalSize
protected void computeContentOptimalSize(Size size)
Description copied from class:WidgetComputes the optimal size of the widget.This method does not consider the border, margin, padding and dimension specified in the style.
The given size is the available size for this widget in its parent. A width or a height equal to
Widget#NO_CONSTRAINTmeans that there is no constraint on this dimension.The given size is modified to set the optimal size.
- Specified by:
computeContentOptimalSizein classWidget- Parameters:
size- the size available for the content.
-
layOutChildren
protected void layOutChildren(int contentWidth, int contentHeight)Description copied from class:ContainerLays out the children of this container.The given size is the size of this container minus the border, margin and padding specified in the style.
When this method returns the children of this container have been lay out using
Container.layOutChild(Widget, int, int, int, int).- Specified by:
layOutChildrenin classContainer- Parameters:
contentWidth- the width available for the content.contentHeight- the height available for the content.
-
-