java.lang.Object
com.vaadin.featurepack.desktop.layouts.AbstractLayout
com.vaadin.featurepack.desktop.layouts.form.FormLayout
All Implemented Interfaces:
Serializable

public class FormLayout extends AbstractLayout
FormLayout is a flexible layout that aligns components in a rectangular grid of cells, with each component occupying one or more cells.
Author:
Vaadin Ltd
See Also:
  • Constructor Details

    • FormLayout

      public FormLayout()
      Constructs a new FormLayout.
    • FormLayout

      public FormLayout(String encodedColumnSpecs, String encodedRowSpecs)
      Constructs a FormLayout using the given column and row specifications.
      Parameters:
      encodedColumnSpecs - encoded column specifications, not null.
      encodedRowSpecs - encoded row specifications, not null.
    • FormLayout

      public FormLayout(ColumnSpec[] colSpecs, RowSpec[] rowSpecs)
      Constructs a FormLayout using the given column and row specifications.
      Parameters:
      colSpecs - an array of column specifications.
      rowSpecs - an array of row specifications.
      Throws:
      NullPointerException - if colSpecs or rowSpecs is null
  • Method Details

    • onContainerAttach

      protected void onContainerAttach(com.vaadin.flow.component.AttachEvent event)
      Overrides:
      onContainerAttach in class AbstractLayout
    • setContainer

      public void setContainer(com.vaadin.flow.component.Component container)
      Overrides:
      setContainer in class AbstractLayout
    • addComponent

      public void addComponent(com.vaadin.flow.component.Component component)
      Overrides:
      addComponent in class AbstractLayout
    • removeComponent

      public void removeComponent(com.vaadin.flow.component.Component component)
      Overrides:
      removeComponent in class AbstractLayout
    • setConstraints

      public void setConstraints(com.vaadin.flow.component.Component component, Object constraints)
      Specified by:
      setConstraints in class AbstractLayout
    • getConstraints

      public Object getConstraints(com.vaadin.flow.component.Component component)
      Specified by:
      getConstraints in class AbstractLayout
    • getColumnCount

      public int getColumnCount()
      Returns the number of columns in this layout.
      Returns:
      the number of columns
    • getColumnSpec

      public ColumnSpec getColumnSpec(int columnIndex)
      Returns the ColumnSpec at the specified column index.
      Parameters:
      columnIndex - the column index of the requested ColumnSpec
      Returns:
      the ColumnSpec at the specified column
      Throws:
      IndexOutOfBoundsException - if the column index is out of range
    • appendColumn

      public void appendColumn(ColumnSpec columnSpec)
      Appends the given column specification to the right hand side of all columns.
      Parameters:
      columnSpec - the column specification to be added
      Throws:
      NullPointerException - if columnSpec is null
    • insertColumn

      public void insertColumn(int columnIndex, ColumnSpec columnSpec)
      Inserts the specified column at the specified position. Shifts components that intersect the new column to the right hand side.

      The component shift works as follows: components that were located on the right hand side of the inserted column are shifted one column to the right; component column span is increased by one if it intersects the new column.

      Parameters:
      columnIndex - index of the column to be inserted
      columnSpec - specification of the column to be inserted
      Throws:
      IndexOutOfBoundsException - if the column index is out of range
    • removeColumn

      public void removeColumn(int columnIndex)
      Removes the column with the given column index from the layout. The column must not contain components.

      The component shift works as follows: components that were located on the right hand side of the removed column are moved one column to the left; component column span is decreased by one if it intersects the removed column.

      Parameters:
      columnIndex - index of the column to remove
      Throws:
      IndexOutOfBoundsException - if the column index is out of range
      IllegalStateException - if the column contains components
    • getRowCount

      public int getRowCount()
      Returns the number of rows in this layout.
      Returns:
      the number of rows
    • getRowSpec

      public RowSpec getRowSpec(int rowIndex)
      Returns the RowSpec at the specified row index.
      Parameters:
      rowIndex - the row index of the requested RowSpec
      Returns:
      the RowSpec at the specified row
      Throws:
      IndexOutOfBoundsException - if the row index is out of range
    • appendRow

      public void appendRow(RowSpec rowSpec)
      Appends the given row specification to the bottom of all rows.
      Parameters:
      rowSpec - the row specification to be added to the form layout
      Throws:
      NullPointerException - if rowSpec is null
    • insertRow

      public void insertRow(int rowIndex, RowSpec rowSpec)
      Inserts the specified row at the specified position. Shifts components that intersect the new row to the bottom and readjusts row groups.

      The component shift works as follows: components that were located below the inserted row are shifted one row to the bottom; component row span is increased by one if it intersects the new row.

      Row group indices that are greater or equal than the given row index will be increased by one.

      Parameters:
      rowIndex - index of the row to be inserted
      rowSpec - specification of the row to be inserted
      Throws:
      IndexOutOfBoundsException - if the row index is out of range
    • removeRow

      public void removeRow(int rowIndex)
      Removes the row with the given row index from the layout. The row must not contain components

      The component shift works as follows: components that were located below the removed row are moved up one row; component row span is decreased by one if it intersects the removed row.

      Parameters:
      rowIndex - index of the row to remove
      Throws:
      IndexOutOfBoundsException - if the row index is out of range
      IllegalStateException - if the row contains components or if the row is already grouped