Package totalcross.ui

Class FlowContainer


  • public class FlowContainer
    extends Container
    This class is a Container that will place controls one after the other and, once the width has been reached, it wraps to next line. Example:
     Settings.uiAdjustmentsBasedOnFontHeight = true;
     
     Label l = new Label("Do you agree that TotalCross is a great development platform?");
     l.autoSplit = true;
     add(l, LEFT,AFTER,PARENTSIZE+100,PREFERRED);
     
     FlowContainer fc = new FlowContainer(50,25);
     fc.add(new Radio("Probably Yes"));
     fc.add(new Radio("Probably No"));
     fc.add(new Radio("Maybe"));
     add(fc, LEFT,AFTER,PARENTSIZE+100,PREFERRED);
     
    All controls must be added before calling setRect. When calling setRect for this control, the height must be PREFERRED (with adjustments, if needed). Also, if initUI is overriden, be sure to call super.initUI(). IT IS VERY IMPORTANT THAT YOU USE PARENTSIZE+100 INSTEAD OF FILL IN THE WIDTH PARAMETER!
    Since:
    TotalCross 1.39
    • Field Detail

      • lines

        protected int lines
    • Constructor Detail

      • FlowContainer

        public FlowContainer​(int hgap,
                             int vgap)
        Constructs a FlowContainer with the given horizontal and vertical gaps. You must add all children controls before calling setRect for this container.
    • Method Detail

      • initUI

        public void initUI()
        Places the controls on screen.
        Overrides:
        initUI in class Container
      • onBoundsChanged

        protected void onBoundsChanged​(boolean screenChanged)
        Description copied from class: Control
        Called after a setRect.
        Overrides:
        onBoundsChanged in class Control
        Parameters:
        screenChanged - If the bounds were changed due to a screen change (rotation, collapse)
      • getPreferredHeight

        public int getPreferredHeight()
        Description copied from class: Control
        Returns the preferred height of this control.
        Overrides:
        getPreferredHeight in class Control