Class BaseTableWithButtons

    • Field Detail

      • m_CountModelListener

        protected TableModelListener m_CountModelListener
        the model listener for updating the counts.
    • Constructor Detail

      • BaseTableWithButtons

        public BaseTableWithButtons()
        The default constructor.
      • BaseTableWithButtons

        public BaseTableWithButtons​(TableModel model)
        Initializes the table with the specified model.
        Parameters:
        model - the model to use
    • Method Detail

      • setModel

        public void setModel​(TableModel dataModel)
        Sets the data model for this table to newModel and registers with it for listener notifications from the new data model.
        Parameters:
        dataModel - the new data source for this table
        See Also:
        getModel()
      • getModel

        public TableModel getModel()
        Returns the underlying table model.
        Returns:
        the underlying table model
      • supportsMovingRows

        public boolean supportsMovingRows()
        Returns whether the table model supports moving of rows.
        Returns:
        true if the model supports moving rows around
        See Also:
        MoveableTableModel
      • moveUp

        public void moveUp()
        moves the selected items up by 1.
      • moveDown

        public void moveDown()
        moves the selected items down by 1.
      • moveTop

        public void moveTop()
        moves the selected items to the top.
      • moveBottom

        public void moveBottom()
        moves the selected items to the end.
      • canMoveUp

        public boolean canMoveUp()
        checks whether the selected items can be moved up.
        Returns:
        true if the selected items can be moved
      • canMoveDown

        public boolean canMoveDown()
        checks whether the selected items can be moved down.
        Returns:
        true if the selected items can be moved
      • setColumnModel

        public void setColumnModel​(TableColumnModel columnModel)
        Sets the column model for this table to newModel and registers for listener notifications from the new column model. Also sets the column model of the JTableHeader to columnModel.
        Parameters:
        columnModel - the new data source for this table
        Throws:
        IllegalArgumentException - if columnModel is null
        See Also:
        getColumnModel()
      • setSelectionModel

        public void setSelectionModel​(ListSelectionModel newModel)
        Sets the row selection model for this table to newModel and registers for listener notifications from the new selection model.
        Parameters:
        newModel - the new selection model
        Throws:
        IllegalArgumentException - if newModel is null
        See Also:
        getSelectionModel()
      • setAutoResizeMode

        public void setAutoResizeMode​(int mode)
        Sets the table's auto resize mode when the table is resized.
        Parameters:
        mode - One of 5 legal values: AUTO_RESIZE_OFF, AUTO_RESIZE_NEXT_COLUMN, AUTO_RESIZE_SUBSEQUENT_COLUMNS, AUTO_RESIZE_LAST_COLUMN, AUTO_RESIZE_ALL_COLUMNS
        See Also:
        getAutoResizeMode(), Container.doLayout()
      • getAutoResizeMode

        public int getAutoResizeMode()
        Returns the auto resize mode of the table. The default mode is AUTO_RESIZE_SUBSEQUENT_COLUMNS.
        Returns:
        the autoResizeMode of the table
        See Also:
        setAutoResizeMode(int)
      • setOptimalColumnWidth

        public void setOptimalColumnWidth()
        Sets the optimal column width for all columns. AutoResize must be set to BaseTable.AUTO_RESIZE_OFF.
      • setOptimalColumnWidthBounded

        public void setOptimalColumnWidthBounded​(int max)
        Sets the optimal column width for all columns. AutoResize must be set to BaseTable.AUTO_RESIZE_OFF.
        Parameters:
        max - the maximum width
      • setOptimalColumnWidth

        public void setOptimalColumnWidth​(int column)
        Sets the optimal column width for the specified column. AutoResize must be set to BaseTable.AUTO_RESIZE_OFF.
        Parameters:
        column - the column to resize
      • setOptimalColumnWidthBounded

        public void setOptimalColumnWidthBounded​(int column,
                                                 int max)
        Sets the optimal column width for the specified column. AutoResize must be set to BaseTable.AUTO_RESIZE_OFF.
        Parameters:
        column - the column to resize
        max - the maximum width
      • setRowHeight

        public void setRowHeight​(int rowHeight)
        Sets the height, in pixels, of all cells to rowHeight, revalidates, and repaints. The height of the cells will be equal to the row height minus the row margin.
        Parameters:
        rowHeight - new row height
      • getRowHeight

        public int getRowHeight​(int row)
        Returns the height for the specified row.
        Parameters:
        row - the row to get the height in pixels for
        Returns:
        the row height
      • rowAtPoint

        public int rowAtPoint​(Point point)
        Returns the index of the row that point lies in, or -1 if the result is not in the range [0, getRowCount()-1].
        Parameters:
        point - the location of interest
        Returns:
        the index of the row that point lies in, or -1 if the result is not in the range [0, getRowCount()-1]
      • getSelectedRow

        public int getSelectedRow()
        Returns the index of the first selected row, -1 if no row is selected.
        Returns:
        the index of the first selected row
      • getSelectedColumn

        public int getSelectedColumn()
        Returns the index of the first selected column, -1 if no column is selected.
        Returns:
        the index of the first selected column
      • getSelectedRows

        public int[] getSelectedRows()
        Returns the indices of all selected rows.
        Returns:
        an array of integers containing the indices of all selected rows, or an empty array if no row is selected
        See Also:
        getSelectedRow()
      • setSelectedRow

        public void setSelectedRow​(int row)
        Sets the selected row (clears all others).
        Parameters:
        row - the row to select
      • setSelectedRows

        public void setSelectedRows​(int[] rows)
        Sets the selected rows (clears all others).
        Parameters:
        rows - the rows to select
      • getSelectedColumns

        public int[] getSelectedColumns()
        Returns the indices of all selected columns.
        Returns:
        an array of integers containing the indices of all selected columns, or an empty array if no column is selected
        See Also:
        getSelectedColumn()
      • getSelectedRowCount

        public int getSelectedRowCount()
        Returns the number of selected rows.
        Returns:
        the number of selected rows, 0 if no rows are selected
      • getSelectedColumnCount

        public int getSelectedColumnCount()
        Returns the number of selected columns.
        Returns:
        the number of selected columns, 0 if no columns are selected
      • isRowSelected

        public boolean isRowSelected​(int row)
        Returns true if the specified index is in the valid range of rows, and the row at that index is selected.
        Returns:
        true if row is a valid index and the row at that index is selected (where 0 is the first row)
      • isColumnSelected

        public boolean isColumnSelected​(int column)
        Returns true if the specified index is in the valid range of columns, and the column at that index is selected.
        Parameters:
        column - the column in the column model
        Returns:
        true if column is a valid index and the column at that index is selected (where 0 is the first column)
      • isCellSelected

        public boolean isCellSelected​(int row,
                                      int column)
        Returns true if the specified indices are in the valid range of rows and columns and the cell at the specified position is selected.
        Parameters:
        row - the row being queried
        column - the column being queried
        Returns:
        true if row and column are valid indices and the cell at index (row, column) is selected, where the first row and first column are at index 0
      • scrollRowToVisible

        public void scrollRowToVisible​(int row)
        Scrolls the row into view.
        Parameters:
        row - the row to scroll into view
      • scrollColumnToVisible

        public void scrollColumnToVisible​(int col)
        Scrolls the column into view.
        Parameters:
        col - the column to scroll into view
      • getRowCount

        public int getRowCount()
        Returns the number of rows that can be shown in the JTable, given unlimited space. If a RowSorter with a filter has been specified, the number of rows returned may differ from that of the underlying TableModel.
        Returns:
        the number of rows shown in the JTable
        See Also:
        getColumnCount()
      • getColumnCount

        public int getColumnCount()
        Returns the number of columns in the column model. Note that this may be different from the number of columns in the table model.
        Returns:
        the number of columns in the table
        See Also:
        getRowCount()
      • getColumnName

        public String getColumnName​(int column)
        Returns the name of the column appearing in the view at column position column.
        Parameters:
        column - the column in the view being queried
        Returns:
        the name of the column at position column in the view where the first column is column 0
      • getColumnClass

        public Class<?> getColumnClass​(int column)
        Returns the type of the column appearing in the view at column position column.
        Parameters:
        column - the column in the view being queried
        Returns:
        the type of the column at position column in the view where the first column is column 0
      • getValueAt

        public Object getValueAt​(int row,
                                 int column)
        Returns the cell value at row and column.

        Note: The column is specified in the table view's display order, and not in the TableModel's column order. This is an important distinction because as the user rearranges the columns in the table, the column at a given index in the view will change. Meanwhile the user's actions never affect the model's column ordering.

        Parameters:
        row - the row whose value is to be queried
        column - the column whose value is to be queried
        Returns:
        the Object at the specified cell
      • setValueAt

        public void setValueAt​(Object aValue,
                               int row,
                               int column)
        Sets the value for the cell in the table model at row and column.

        Note: The column is specified in the table view's display order, and not in the TableModel's column order. This is an important distinction because as the user rearranges the columns in the table, the column at a given index in the view will change. Meanwhile the user's actions never affect the model's column ordering. aValue is the new value.

        Parameters:
        aValue - the new value
        row - the row of the cell to be changed
        column - the column of the cell to be changed
        See Also:
        getValueAt(int, int)
      • isCellEditable

        public boolean isCellEditable​(int row,
                                      int column)
        Returns true if the cell at row and column is editable. Otherwise, invoking setValueAt on the cell will have no effect.

        Note: The column is specified in the table view's display order, and not in the TableModel's column order. This is an important distinction because as the user rearranges the columns in the table, the column at a given index in the view will change. Meanwhile the user's actions never affect the model's column ordering.

        Parameters:
        row - the row whose value is to be queried
        column - the column whose value is to be queried
        Returns:
        true if the cell is editable
        See Also:
        setValueAt(java.lang.Object, int, int)
      • setSelectionMode

        public void setSelectionMode​(int selectionMode)
        Sets the table's selection mode to allow only single selections, a single contiguous interval, or multiple intervals.
        Parameters:
        selectionMode - the selection mode to use
        See Also:
        JList.setSelectionMode(int)
      • addRemoveItemsListener

        public void addRemoveItemsListener​(RemoveItemsListener l)
        Adds the remove items listener to its internal list.
        Parameters:
        l - the listener to add
      • removeRemoveItemsListener

        public void removeRemoveItemsListener​(RemoveItemsListener l)
        Removes the remove items listener from its internal list.
        Parameters:
        l - the listener to remove
      • setInfoVisible

        public void setInfoVisible​(boolean value)
        Whether to display the information JLabel or not.
        Overrides:
        setInfoVisible in class AbstractComponentWithButtons<BaseTable>
        Parameters:
        value - if true then the information is being displayed
      • updateCountsModelListener

        protected void updateCountsModelListener​(TableModel dataModel)
        Updates the table model's listener for updating the counts.
        Parameters:
        dataModel - the model to update
      • updateCounts

        protected void updateCounts()
        Updates the information about the counts.
      • showCell

        public void showCell​(int row,
                             int column)
        Displays the specified cell.
        Parameters:
        row - the row of the cell
        column - the column of the cell
      • setShowSimplePopupMenus

        public void setShowSimplePopupMenus​(boolean value)
        Sets whether to show a simple header/cell popup menu.
        Parameters:
        value - true if to show menus
      • setShowSimpleHeaderPopupMenu

        public void setShowSimpleHeaderPopupMenu​(boolean value)
        Sets whether to show a simple header popup menu.
        Parameters:
        value - true if to show menu
      • getShowSimpleHeaderPopupMenu

        public boolean getShowSimpleHeaderPopupMenu()
        Returns whether to show a simple header popup menu.
        Returns:
        true if to show menu
      • setShowSimpleCellPopupMenu

        public void setShowSimpleCellPopupMenu​(boolean value)
        Sets whether to show a simple cell popup menu.
        Parameters:
        value - true if to show menu
      • getShowSimpleCellPopupMenu

        public boolean getShowSimpleCellPopupMenu()
        Returns whether to show a simple cell popup menu.
        Returns:
        true if to show menu
      • getColumnWidths

        public int[] getColumnWidths()
        Returns the column widths.
        Returns:
        the current widths
      • setColumnWidths

        public void setColumnWidths​(int[] value)
        Sets the column widths.
        Parameters:
        value - the widths