Package com.tonic.vellum.widget
Class Table
- java.lang.Object
-
- com.tonic.vellum.Section
-
- com.tonic.vellum.widget.AbstractListSection
-
- com.tonic.vellum.widget.Table
-
public final class Table extends AbstractListSection
A scrollable table with a fixed header and selectable rows; column widths are solved from each column's Constraint, so the header and rows always align and tile the width.
-
-
Constructor Summary
Constructors Constructor Description Table()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TableaddRow(java.lang.String... cells)Appends a row of cells.Tablecolumn(java.lang.String title, Constraint width)Adds a left-aligned column.Tablecolumn(java.lang.String title, Constraint width, Alignment align)Adds a column with the given alignment.TableheaderStyle(Style style)Sets the style used to draw the header row.java.lang.String[]selectedRow()TablesetRows(java.util.List<java.lang.String[]> newRows)Replaces all rows.TableshowHeader(boolean show)Sets whether the header row is shown.-
Methods inherited from class com.tonic.vellum.widget.AbstractListSection
onHighlight, onSelect, select, selectedIndex
-
-
-
-
Method Detail
-
column
public Table column(java.lang.String title, Constraint width)
Adds a left-aligned column.- Parameters:
title- the column header titlewidth- the column width constraint- Returns:
- this Table for chaining
-
column
public Table column(java.lang.String title, Constraint width, Alignment align)
Adds a column with the given alignment.- Parameters:
title- the column header titlewidth- the column width constraintalign- the cell and header alignment- Returns:
- this Table for chaining
-
addRow
public Table addRow(java.lang.String... cells)
Appends a row of cells.- Parameters:
cells- the cell values in column order- Returns:
- this Table for chaining
-
setRows
public Table setRows(java.util.List<java.lang.String[]> newRows)
Replaces all rows.- Parameters:
newRows- the new rows, each an array of cell values- Returns:
- this Table for chaining
-
showHeader
public Table showHeader(boolean show)
Sets whether the header row is shown.- Parameters:
show-trueto show the header- Returns:
- this Table for chaining
-
headerStyle
public Table headerStyle(Style style)
Sets the style used to draw the header row.- Parameters:
style- the header style- Returns:
- this Table for chaining
-
selectedRow
public java.lang.String[] selectedRow()
- Returns:
- the selected row's cells, or null when the table is empty
-
-