Package ej.widget.container
Class Dock
- java.lang.Object
-
- ej.mwt.Widget
-
- ej.mwt.Container
-
- ej.widget.container.Dock
-
public class Dock extends ej.mwt.ContainerLays 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.

-
-
Constructor Summary
Constructors Constructor Description Dock()Creates a dock.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChildOnBottom(ej.mwt.Widget child)Adds a child which will be docked on the bottom side.voidaddChildOnLeft(ej.mwt.Widget child)Adds a child which will be docked on the left side.voidaddChildOnRight(ej.mwt.Widget child)Adds a child which will be docked on the right side.voidaddChildOnTop(ej.mwt.Widget child)Adds a child which will be docked on the top side.protected voidcomputeContentOptimalSize(ej.mwt.util.Size size)ej.mwt.WidgetgetCenterChild()Gets the child at the center of this dock.protected voidlayOutChildren(int contentWidth, int contentHeight)voidremoveAllChildren()voidremoveChild(ej.mwt.Widget child)voidsetCenterChild(ej.mwt.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
-
-
-
-
Method Detail
-
addChildOnLeft
public void addChildOnLeft(ej.mwt.Widget child)
Adds a child which will be docked on the left side.- Parameters:
child- the widget to add.- Throws:
java.lang.NullPointerException- if the given widget isnull.java.lang.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(ej.mwt.Widget child)
Adds a child which will be docked on the right side.- Parameters:
child- the widget to add.- Throws:
java.lang.NullPointerException- if the given widget isnull.java.lang.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(ej.mwt.Widget child)
Adds a child which will be docked on the top side.- Parameters:
child- the widget to add.- Throws:
java.lang.NullPointerException- if the given widget isnull.java.lang.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(ej.mwt.Widget child)
Adds a child which will be docked on the bottom side.- Parameters:
child- the widget to add.- Throws:
java.lang.NullPointerException- if the given widget isnull.java.lang.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(ej.mwt.Widget child)
Sets the child which will be at the center.- Parameters:
child- the widget to add.- Throws:
java.lang.NullPointerException- if the given widget isnull.java.lang.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 ej.mwt.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(ej.mwt.Widget child)
- Overrides:
removeChildin 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
-
-