Class Dock
- java.lang.Object
-
- ej.mwt.Widget
-
- ej.mwt.Container
-
- ej.widget.container.Dock
-
public class Dock extends Container
Lays out any number of children by docking each child one by one on a side.Each child is laid out individually on one of the sides of the remaining space, following the order in which they have been added to the dock. If a widget is set at the center of the dock, it will take the final remaining space.
In a dock, all widgets docked on the left side and on the right side will have the height of the remaining space and will have their optimal width. All widgets docked on the top side and on the bottom side will have the width of the remaining space and will have their optimal height. The center widget will have the size of the remaining space.
Example of dock that contains (added in this order):
- widget on the left,
- widget on the top,
- widget on the right,
- widget on the bottom,
- widget on the left,
- widget on the bottom,
- widget on the center.

-
-
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 Dock()Creates a dock.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChildOnBottom(Widget child)Adds a child which will be docked on the bottom side.voidaddChildOnLeft(Widget child)Adds a child which will be docked on the left side.voidaddChildOnRight(Widget child)Adds a child which will be docked on the right side.voidaddChildOnTop(Widget child)Adds a child which will be docked on the top side.protected voidcomputeContentOptimalSize(Size size)Computes the optimal size of the widget.WidgetgetCenterChild()Gets the child at the center of this dock.protected voidlayOutChildren(int contentWidth, int contentHeight)Lays out the children of this container.voidremoveAllChildren()Removes all the children of this container.voidremoveChild(Widget child)Removes the specified widget from the list of children of this container.voidsetCenterChild(Widget child)Sets the child which will be at the center.-
Methods inherited from class ej.mwt.Container
addChild, changeChildIndex, computeChildOptimalSize, getChild, getChildIndex, getChildren, getChildrenCount, getContentBounds, getContentHeight, getContentWidth, getContentX, getContentY, getWidgetAt, insertChild, layOutAlignedChild, layOutChild, 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
-
-
-
-
Method Detail
-
addChildOnLeft
public void addChildOnLeft(Widget child)
Adds a child which will be docked on the left side.- Parameters:
child- the widget to add.- Throws:
NullPointerException- if the given widget isnull.IllegalArgumentException- if the specified widget is already in a hierarchy (already contained in a container or desktop).- See Also:
Container.addChild(Widget)
-
addChildOnRight
public void addChildOnRight(Widget child)
Adds a child which will be docked on the right side.- Parameters:
child- the widget to add.- Throws:
NullPointerException- if the given widget isnull.IllegalArgumentException- if the specified widget is already in a hierarchy (already contained in a container or desktop).- See Also:
Container.addChild(Widget)
-
addChildOnTop
public void addChildOnTop(Widget child)
Adds a child which will be docked on the top side.- Parameters:
child- the widget to add.- Throws:
NullPointerException- if the given widget isnull.IllegalArgumentException- if the specified widget is already in a hierarchy (already contained in a container or desktop).- See Also:
Container.addChild(Widget)
-
addChildOnBottom
public void addChildOnBottom(Widget child)
Adds a child which will be docked on the bottom side.- Parameters:
child- the widget to add.- Throws:
NullPointerException- if the given widget isnull.IllegalArgumentException- if the specified widget is already in a hierarchy (already contained in a container or desktop).- See Also:
Container.addChild(Widget)
-
setCenterChild
public void setCenterChild(Widget child)
Sets the child which will be at the center.- Parameters:
child- the widget to add.- Throws:
NullPointerException- if the given widget isnull.IllegalArgumentException- if the specified widget is already in a hierarchy (already contained in a container or desktop).- See Also:
Container.addChild(Widget)
-
getCenterChild
@Nullable public Widget getCenterChild()
Gets the child at the center of this dock.- Returns:
- the center child, or
nullis it has not been set.
-
removeChild
public void removeChild(Widget child)
Description copied from class:ContainerRemoves the specified widget from the list of children of this container.The container needs to be laid out again.
If the widget is not in the list of children of the container, nothing is done.
Should be called in the display thread to avoid concurrency issues.
- Overrides:
removeChildin classContainer- Parameters:
child- the widget to remove.- See Also:
Widget.requestLayOut()
-
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.
-
-