# 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
  `final TableLayout`
  `table`
  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`
  `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.
  `TableLayout.Constraint`
  `cc()`
  Creates a new Constraint instance to add to the layout
  `TableLayout.Constraint`
  `cc(int row, int column)`
  Creates a new Constraint instance to add to the layout
  `Object`
  `cloneConstraint(Object constraint)`
  `TableLayout.Constraint`
  `createConstraint()`
  Creates a new Constraint instance to add to the layout
  `TableLayout.Constraint`
  `createConstraint(int row, int column)`
  Creates a new Constraint instance to add to the layout
  `Object`
  `getComponentConstraint(Component comp)`
  Returns the optional component constraint
  `Dimension`
  `getPreferredSize(Container parent)`
  Returns the container preferred size
  `boolean`
  `isAutoGrouping()`
  Automatically invokes the `com.codename1.ui.InputComponent#group(com.codename1.ui.Component...)` method on the text components in a BoxY layout scenario
  `boolean`
  `isConstraintTracking()`
  If this method returns true, the addLayoutComponent method will be called when replacing a layout for every component within the container
  `boolean`
  `isOverlapSupported()`
  This method returns true if the Layout allows Components to Overlap.
  `void`
  `layoutContainer(Container parent)`
  Layout the given parent container children
  `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.
  `void`
  `removeLayoutComponent(Component comp)`
  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`

  ### Methods inherited from class Object

  `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- ## 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

    public TableLayout.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