Class FormLayout
- All Implemented Interfaces:
Serializable
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 Summary
ConstructorsConstructorDescriptionConstructs a newFormLayout.FormLayout(ColumnSpec[] colSpecs, RowSpec[] rowSpecs) Constructs aFormLayoutusing the given column and row specifications.FormLayout(String encodedColumnSpecs, String encodedRowSpecs) Constructs aFormLayoutusing the given column and row specifications. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddComponent(com.vaadin.flow.component.Component component) voidappendColumn(ColumnSpec columnSpec) Appends the given column specification to the right hand side of all columns.voidAppends the given row specification to the bottom of all rows.intReturns the number of columns in this layout.getColumnSpec(int columnIndex) Returns theColumnSpecat the specified column index.getConstraints(com.vaadin.flow.component.Component component) intReturns the number of rows in this layout.getRowSpec(int rowIndex) Returns theRowSpecat the specified row index.voidinsertColumn(int columnIndex, ColumnSpec columnSpec) Inserts the specified column at the specified position.voidInserts the specified row at the specified position.protected voidonContainerAttach(com.vaadin.flow.component.AttachEvent event) voidremoveColumn(int columnIndex) Removes the column with the given column index from the layout.voidremoveComponent(com.vaadin.flow.component.Component component) voidremoveRow(int rowIndex) Removes the row with the given row index from the layout.voidsetConstraints(com.vaadin.flow.component.Component component, Object constraints) voidsetContainer(com.vaadin.flow.component.Component container) Methods inherited from class com.vaadin.featurepack.desktop.layouts.AbstractLayout
getComponents, getContainer, onContainerDetach
-
Constructor Details
-
FormLayout
public FormLayout()Constructs a newFormLayout. -
FormLayout
Constructs aFormLayoutusing the given column and row specifications.- Parameters:
encodedColumnSpecs- encoded column specifications, notnull.encodedRowSpecs- encoded row specifications, notnull.
-
FormLayout
Constructs aFormLayoutusing the given column and row specifications.- Parameters:
colSpecs- an array of column specifications.rowSpecs- an array of row specifications.- Throws:
NullPointerException- ifcolSpecsorrowSpecsisnull
-
-
Method Details
-
onContainerAttach
protected void onContainerAttach(com.vaadin.flow.component.AttachEvent event) - Overrides:
onContainerAttachin classAbstractLayout
-
setContainer
public void setContainer(com.vaadin.flow.component.Component container) - Overrides:
setContainerin classAbstractLayout
-
addComponent
public void addComponent(com.vaadin.flow.component.Component component) - Overrides:
addComponentin classAbstractLayout
-
removeComponent
public void removeComponent(com.vaadin.flow.component.Component component) - Overrides:
removeComponentin classAbstractLayout
-
setConstraints
- Specified by:
setConstraintsin classAbstractLayout
-
getConstraints
- Specified by:
getConstraintsin classAbstractLayout
-
getColumnCount
public int getColumnCount()Returns the number of columns in this layout.- Returns:
- the number of columns
-
getColumnSpec
Returns theColumnSpecat the specified column index.- Parameters:
columnIndex- the column index of the requestedColumnSpec- Returns:
- the
ColumnSpecat the specified column - Throws:
IndexOutOfBoundsException- if the column index is out of range
-
appendColumn
Appends the given column specification to the right hand side of all columns.- Parameters:
columnSpec- the column specification to be added- Throws:
NullPointerException- ifcolumnSpecisnull
-
insertColumn
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 insertedcolumnSpec- 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 rangeIllegalStateException- if the column contains components
-
getRowCount
public int getRowCount()Returns the number of rows in this layout.- Returns:
- the number of rows
-
getRowSpec
Returns theRowSpecat the specified row index.- Parameters:
rowIndex- the row index of the requestedRowSpec- Returns:
- the
RowSpecat the specified row - Throws:
IndexOutOfBoundsException- if the row index is out of range
-
appendRow
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- ifrowSpecisnull
-
insertRow
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 insertedrowSpec- 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 componentsThe 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 rangeIllegalStateException- if the row contains components or if the row is already grouped
-