Class ViewTableModel

All Implemented Interfaces:
Serializable, TableModel

public class ViewTableModel extends DefaultTableModel implements Serializable
This is a simple class that creates a DefaultTableModel with uneditable cells. With the cells uneditable, the table may react to mouse events, such as double clicking on a row.
Version:
0.1 June 30, 1999
Author:
Neva Cherniavsky
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      Use serialVersionUID for interoperability.
      See Also:
  • Constructor Details

    • ViewTableModel

      public ViewTableModel()
      Calls super constructor.
    • ViewTableModel

      public ViewTableModel(Object[] columnNames, int rowCount)
      Constructs a new table model with the given column names and row count.
      Parameters:
      columnNames - Names of columns.
      rowCount - Number of rows.
  • Method Details

    • clone

      public Object clone()
      Copies the object that extends this class.
      Overrides:
      clone in class Object
      Returns:
      An exact copy of this class.
    • getColumnClass

      public Class<? extends Object> getColumnClass(int col)
      Returns the class of the item in the column.
      Specified by:
      getColumnClass in interface TableModel
      Overrides:
      getColumnClass in class AbstractTableModel
      Parameters:
      col - Column index.
      Returns:
      Class of column.
    • getColumnIndex

      public int getColumnIndex(String name)
      Gets the index of the given column name.
      Parameters:
      name - Name of column.
      Returns:
      Index of column when created, or -1 if none.
    • getColumnStartsWithIndex

      public int getColumnStartsWithIndex(String name)
      Gets the index of a column name that starts with the given string
      Parameters:
      name - String name of column
      Returns:
      int Index of column, or -1 if none
    • getColumnBaseIndex

      public int getColumnBaseIndex(String name)
      Gets the index of the given column name.
      Parameters:
      name - Name of column.
      Returns:
      Index of column when created, or -1 if none.
    • isCellEditable

      public boolean isCellEditable(int x, int y)
      Returns false for all cells, so none can be edited.
      Specified by:
      isCellEditable in interface TableModel
      Overrides:
      isCellEditable in class DefaultTableModel
      Parameters:
      x - x value of cell
      y - y value of cell
      Returns:
      false, always
    • setColumnName

      public void setColumnName(int col, Object newName)
      Sets the column name to the new name and fires the table event. Table widths must be reset after this call.
      Parameters:
      col - Column to rename
      newName - New name.
    • setValueAt

      public void setValueAt(Object value, int row, int col)
      Sets the value at the given row and column of the table.
      Specified by:
      setValueAt in interface TableModel
      Overrides:
      setValueAt in class DefaultTableModel
      Parameters:
      value - Value to set.
      row - Row to set value at.
      col - Column to set value at.
    • updateBulbs

      public void updateBulbs(int selectedRow)
      Updates the bulbs.
      Parameters:
      selectedRow - Row to update.
    • getRowLength

      public int getRowLength(int row)
      Gets the length of a row in the model
      Parameters:
      row - index of row to get
      Returns:
      length of vector at index row
    • getRow

      public Object[] getRow(int row)