Class RowNumberTableModel

java.lang.Object
javax.swing.table.AbstractTableModel
org.ka2ddo.yaac.gui.table.RowNumberTableModel
All Implemented Interfaces:
Serializable, EventListener, TableModelListener, TableModel

public class RowNumberTableModel extends AbstractTableModel implements TableModelListener
This table model counts rows, suitable for the row header of a JScrollPane surrounding a JTable.
Author:
Andrew Pavlin, KA2DDO
See Also:
  • Constructor Details

    • RowNumberTableModel

      public RowNumberTableModel(TableModel rootTable)
      Create a table model for displaying row numbers for another table.
      Parameters:
      rootTable - TableModel whose rows should be numbered in the tow header of a table
  • Method Details

    • getRowCount

      public int getRowCount()
      Returns the number of rows in the model. A JTable uses this method to determine how many rows it should display. This method should be quick, as it is called frequently during rendering.
      Specified by:
      getRowCount in interface TableModel
      Returns:
      the number of rows in the model
      See Also:
    • getColumnCount

      public int getColumnCount()
      Returns the number of columns in the model. A JTable uses this method to determine how many columns it should create and display by default.
      Specified by:
      getColumnCount in interface TableModel
      Returns:
      the number of columns in the model
      See Also:
    • getColumnName

      public String getColumnName(int column)
      Returns a default name for the column using spreadsheet conventions: A, B, C, ... Z, AA, AB, etc. If column cannot be found, returns an empty string.
      Specified by:
      getColumnName in interface TableModel
      Overrides:
      getColumnName in class AbstractTableModel
      Parameters:
      column - the column being queried
      Returns:
      a string containing the default name of column
    • getColumnClass

      public Class<?> getColumnClass(int columnIndex)
      Returns String.class regardless of columnIndex.
      Specified by:
      getColumnClass in interface TableModel
      Overrides:
      getColumnClass in class AbstractTableModel
      Parameters:
      columnIndex - the column being queried
      Returns:
      the String.class
    • getValueAt

      public Object getValueAt(int rowIndex, int columnIndex)
      Returns the value for the cell at columnIndex and rowIndex.
      Specified by:
      getValueAt in interface TableModel
      Parameters:
      rowIndex - the row whose value is to be queried
      columnIndex - the column whose value is to be queried
      Returns:
      the value Object at the specified cell
    • tableChanged

      public void tableChanged(TableModelEvent e)
      This fine grain notification tells listeners the exact range of cells, rows, or columns that changed.
      Specified by:
      tableChanged in interface TableModelListener
      Parameters:
      e - TableModelEvent reporting the change in the other table model