Class 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 Detail

      • Table

        public Table()
    • Method Detail

      • column

        public Table column​(java.lang.String title,
                            Constraint width)
        Adds a left-aligned column.
        Parameters:
        title - the column header title
        width - 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 title
        width - the column width constraint
        align - 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 - true to 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