Class Canvas


  • public class Canvas
    extends ej.mwt.Container
    Lays out any number of children freely.

    Each child is laid out at the position it has been given.

    In a canvas, each child will have the size it has been given, or if desired, its optimal size.

    • Field Summary

      • Fields inherited from class ej.mwt.Widget

        NO_CONSTRAINT
    • Constructor Summary

      Constructors 
      Constructor Description
      Canvas()
      Creates a canvas.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addChild​(ej.mwt.Widget child, int x, int y, int width, int height)
      Adds the specified widget to this canvas.
      void changeChildIndex​(ej.mwt.Widget child, int index)  
      protected void computeContentOptimalSize​(ej.mwt.util.Size size)  
      protected void layOutChildren​(int contentWidth, int contentHeight)  
      void removeAllChildren()  
      void removeChild​(ej.mwt.Widget child)  
      • Methods inherited from class ej.mwt.Container

        addChild, 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
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Canvas

        public Canvas()
        Creates a canvas.
    • Method Detail

      • addChild

        public void addChild​(ej.mwt.Widget child,
                             int x,
                             int y,
                             int width,
                             int height)
        Adds the specified widget to this canvas. The widget is laid out with the given bounds.

        If the given width or height is Widget.NO_CONSTRAINT, the widget is fitted to its optimal width/height.

        Parameters:
        child - the widget to add.
        x - the x coordinate of the widget.
        y - the y coordinate of the widget.
        width - the width of the widget, or Widget.NO_CONSTRAINT to use the widget optimal width.
        height - the height of the widget, or Widget.NO_CONSTRAINT to use the widget optimal height.
        Throws:
        java.lang.NullPointerException - if the specified widget is null.
        java.lang.IllegalArgumentException - if the specified widget is already in a hierarchy (already contained in a container or desktop).
        See Also:
        Container.addChild(Widget)
      • removeChild

        public void removeChild​(ej.mwt.Widget child)
        Overrides:
        removeChild in class ej.mwt.Container
      • removeAllChildren

        public void removeAllChildren()
        Overrides:
        removeAllChildren in class ej.mwt.Container
      • changeChildIndex

        public void changeChildIndex​(ej.mwt.Widget child,
                                     int index)
        Overrides:
        changeChildIndex in class ej.mwt.Container
      • computeContentOptimalSize

        protected void computeContentOptimalSize​(ej.mwt.util.Size size)
        Specified by:
        computeContentOptimalSize in class ej.mwt.Widget
      • layOutChildren

        protected void layOutChildren​(int contentWidth,
                                      int contentHeight)
        Specified by:
        layOutChildren in class ej.mwt.Container