Class 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):

    1. widget on the left,
    2. widget on the top,
    3. widget on the right,
    4. widget on the bottom,
    5. widget on the left,
    6. widget on the bottom,
    7. widget on the center.
    Dock.
    • Constructor Detail

      • Dock

        public Dock()
        Creates a dock.
    • Method Detail

      • 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 is null.
        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 null is it has not been set.
      • removeChild

        public void removeChild​(Widget child)
        Description copied from class: Container
        Removes 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:
        removeChild in class Container
        Parameters:
        child - the widget to remove.
        See Also:
        Widget.requestLayOut()
      • removeAllChildren

        public void removeAllChildren()
        Description copied from class: Container
        Removes 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:
        removeAllChildren in class Container
        See Also:
        Widget.requestLayOut()
      • computeContentOptimalSize

        protected void computeContentOptimalSize​(Size size)
        Description copied from class: Widget
        Computes 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_CONSTRAINT means that there is no constraint on this dimension.

        The given size is modified to set the optimal size.

        Specified by:
        computeContentOptimalSize in class Widget
        Parameters:
        size - the size available for the content.
      • layOutChildren

        protected void layOutChildren​(int contentWidth,
                                      int contentHeight)
        Description copied from class: Container
        Lays 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:
        layOutChildren in class Container
        Parameters:
        contentWidth - the width available for the content.
        contentHeight - the height available for the content.