Class TextModeLayout

java.lang.Object
com.codename1.ui.layouts.Layout
com.codename1.ui.layouts.TextModeLayout

public class TextModeLayout extends Layout

This is a special case layout specifically designed for com.codename1.ui.InputComponent. When the on top mode of text layout is used this layout acts exactly like a table layout and uses the given constraints. When this mode is false it uses a regular box Y layout mode and orders the elements one on top of the other.

One important difference between this layout and the default table layout is that the vertical alignment here is set to TOP so the error label below doesn't break component alignment if two components are on the same row and only one has an error message.

The following code demonstrates a simple set of inputs and validation as it appears in iOS, Android and with validation errors

TextModeLayout tl = new TextModeLayout(3, 2);
Form f = new Form("Pixel Perfect", tl);

TextComponent title = new TextComponent().label("Title");
TextComponent price = new TextComponent().label("Price");
TextComponent location = new TextComponent().label("Location");
PickerComponent date = PickerComponent.createDate(new Date()).label("Date");
TextComponent description = new TextComponent().label("Description").multiline(true);

Validator val = new Validator();
val.addConstraint(title, new LengthConstraint(2));
val.addConstraint(price, new NumericConstraint(true));

f.add(tl.createConstraint().widthPercentage(60), title);
f.add(tl.createConstraint().widthPercentage(40), date);
f.add(location);
f.add(price);
f.add(tl.createConstraint().horizontalSpan(2), description);
f.setEditOnShow(title.getField());

f.show();
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    The underlying table layout can be used freely to create constraints on the fly
  • Constructor Summary

    Constructors
    Constructor
    Description
    TextModeLayout(int rows, int columns)
    The constructor works like the standard table layout constructor and will behave as such with the on top mode
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Some layouts can optionally track the addition of elements with meta-data that allows the user to "hint" on object positioning.
    cc()
    Creates a new Constraint instance to add to the layout
    cc(int row, int column)
    Creates a new Constraint instance to add to the layout
    cloneConstraint(Object constraint)
    Creates a new Constraint instance to add to the layout
    createConstraint(int row, int column)
    Creates a new Constraint instance to add to the layout
    Returns the optional component constraint
    Returns the container preferred size
    boolean
    Automatically invokes the com.codename1.ui.InputComponent#group(com.codename1.ui.Component...) method on the text components in a BoxY layout scenario
    boolean
    If this method returns true, the addLayoutComponent method will be called when replacing a layout for every component within the container
    boolean
    This method returns true if the Layout allows Components to Overlap.
    void
    Layout the given parent container children
    boolean
    Some layout managers can obscure their child components in some cases this returns true if the basic underpinnings are in place for that.
    void
    Removes the component from the layout this operation is only useful if the layout maintains references to components within it
    void
    setAutoGrouping(boolean autoGrouping)
    Automatically invokes the com.codename1.ui.InputComponent#group(com.codename1.ui.Component...) method on the text components in a BoxY layout scenario

    Methods inherited from class Layout

    equals, getChildrenInTraversalOrder, hashCode, overridesTabIndices, updateTabIndices
    Modifier and Type
    Method
    Description
    boolean
    Indicates whether some other object is "equal to" this one.
    protected Component[]
    Gets the children of the parent container in the order that they should be traversed when tabbing through a form.
    int
    Returns a hash code value for the object.
    boolean
    If a layout specifies a different traversal order of its components than the component index, then it should override this method to return true, and it should also override #getChildrenInTraversalOrder(com.codename1.ui.Container) to set the tab indices of a container's children.
    final int
    updateTabIndices(Container parent, int offset)
    Updates the tab traversal order

    Methods inherited from class Object

    clone, getClass, notify, notifyAll, toString, wait, wait, wait
    Modifier and Type
    Method
    Description
    protected Object
     
    final Class
    Returns the runtime class of an object.
    final void
    Wakes up a single thread that is waiting on this object's monitor.
    final void
    Wakes up all threads that are waiting on this object's monitor.
    Returns a string representation of the object.
    final void
    Causes current thread to wait until another thread invokes the method or the method for this object.
    final void
    wait(long timeout)
    Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.
    final void
    wait(long timeout, int nanos)
    Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
  • Field Details

    • table

      public final TableLayout table
      The underlying table layout can be used freely to create constraints on the fly
  • Constructor Details

    • TextModeLayout

      public TextModeLayout(int rows, int columns)

      The constructor works like the standard table layout constructor and will behave as such with the on top mode

      Parameters
      • rows: the number of rows

      • columns: the number of columns;

  • Method Details

    • addLayoutComponent

      public void addLayoutComponent(Object value, Component comp, Container c)

      Some layouts can optionally track the addition of elements with meta-data that allows the user to "hint" on object positioning.

      Parameters
      • value: optional meta data information, like alignment orientation

      • comp: the added component to the layout

      • c: the parent container

      Overrides:
      addLayoutComponent in class Layout
    • cloneConstraint

      public Object cloneConstraint(Object constraint)
      Overrides:
      cloneConstraint in class Layout
    • getComponentConstraint

      public Object getComponentConstraint(Component comp)

      Returns the optional component constraint

      Parameters
      • comp: the component whose constraint should be returned
      Returns

      the optional component constraint

      Overrides:
      getComponentConstraint in class Layout
    • isConstraintTracking

      public boolean isConstraintTracking()

      If this method returns true, the addLayoutComponent method will be called when replacing a layout for every component within the container

      Returns

      false by default

      Overrides:
      isConstraintTracking in class Layout
    • isOverlapSupported

      public boolean isOverlapSupported()

      This method returns true if the Layout allows Components to Overlap.

      Returns

      true if Components may intersect in this layout

      Overrides:
      isOverlapSupported in class Layout
    • obscuresPotential

      public boolean obscuresPotential(Container parent)

      Some layout managers can obscure their child components in some cases this returns true if the basic underpinnings are in place for that. This method doesn't take padding/margin etc. into account since that is checked by the caller

      Parameters
      • parent: parent container
      Returns

      true if there is a chance that this layout manager can fully obscure the background, when in doubt return false...

      Overrides:
      obscuresPotential in class Layout
    • removeLayoutComponent

      public void removeLayoutComponent(Component comp)

      Removes the component from the layout this operation is only useful if the layout maintains references to components within it

      Parameters
      • comp: the removed component from layout
      Overrides:
      removeLayoutComponent in class Layout
    • layoutContainer

      public void layoutContainer(Container parent)

      Layout the given parent container children

      Parameters
      • parent: the given parent container
      Specified by:
      layoutContainer in class Layout
    • getPreferredSize

      public Dimension getPreferredSize(Container parent)

      Returns the container preferred size

      Parameters
      • parent: the parent container
      Returns

      the container preferred size

      Specified by:
      getPreferredSize in class Layout
    • createConstraint

      public TableLayout.Constraint createConstraint()

      Creates a new Constraint instance to add to the layout

      Returns

      the default constraint

    • cc

      Creates a new Constraint instance to add to the layout

      Returns

      the default constraint

    • createConstraint

      public TableLayout.Constraint createConstraint(int row, int column)

      Creates a new Constraint instance to add to the layout

      Parameters
      • row: the row for the table starting with 0

      • column: the column for the table starting with 0

      Returns

      the new constraint

    • cc

      public TableLayout.Constraint cc(int row, int column)

      Creates a new Constraint instance to add to the layout

      Parameters
      • row: the row for the table starting with 0

      • column: the column for the table starting with 0

      Returns

      the default constraint

    • isAutoGrouping

      public boolean isAutoGrouping()

      Automatically invokes the com.codename1.ui.InputComponent#group(com.codename1.ui.Component...) method on the text components in a BoxY layout scenario

      Returns

      the autoGrouping

    • setAutoGrouping

      public void setAutoGrouping(boolean autoGrouping)

      Automatically invokes the com.codename1.ui.InputComponent#group(com.codename1.ui.Component...) method on the text components in a BoxY layout scenario

      Parameters
      • autoGrouping: the autoGrouping to set