public class TextModeLayout

  1. Object
  2. Layout
  3. TextModeLayout

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();

Fields

public final TableLayout tableThe underlying table layout can be used freely to create constraints on the fly

Constructors

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

Methods

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.
public Object cloneConstraint(Object constraint)
public Object getComponentConstraint(Component comp)Returns the optional component constraint
public boolean isConstraintTracking()If this method returns true, the addLayoutComponent method will be called when replacing a layout for every component within the container
public boolean isOverlapSupported()This method returns true if the Layout allows Components to Overlap.
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.
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
public void layoutContainer(Container parent)Layout the given parent container children
public Dimension getPreferredSize(Container parent)Returns the container preferred size
public TableLayout.Constraint createConstraint()Creates a new Constraint instance to add to the layout
public TableLayout.Constraint cc()Creates a new Constraint instance to add to the layout
public TableLayout.Constraint createConstraint(int row, int column)Creates a new Constraint instance to add to the layout
public TableLayout.Constraint cc(int row, int column)Creates a new Constraint instance to add to the layout
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
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

Inherited methods

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 int
the number of rows
columns int
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 Object
optional meta data information, like alignment orientation
comp Component
the added component to the layout
c Container
the parent container

cloneConstraint

public Object cloneConstraint(Object constraint)

getComponentConstraint

public Object getComponentConstraint(Component comp)
Returns the optional component constraint

Parameters

comp Component
the component whose constraint should be returned

Returns

the optional component constraint

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

isOverlapSupported

public boolean isOverlapSupported()
This method returns true if the Layout allows Components to Overlap.

Returns

true if Components may intersect in this 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 Container
parent container

Returns

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

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 Component
the removed component from layout

layoutContainer

public void layoutContainer(Container parent)
Layout the given parent container children

Parameters

parent Container
the given parent container

getPreferredSize

public Dimension getPreferredSize(Container parent)
Returns the container preferred size

Parameters

parent Container
the parent container

Returns

the container preferred size

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 int
the row for the table starting with 0
column int
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 int
the row for the table starting with 0
column int
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 boolean
the autoGrouping to set