Class ObjectTableModel

  • All Implemented Interfaces:
    java.io.Serializable, javax.swing.table.TableModel

    public class ObjectTableModel
    extends javax.swing.table.AbstractTableModel
    The object table model has associated an object with each row.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.HashMap columnclasses
      The classes of the columns.
      protected java.util.Vector columns
      The data.
      protected java.util.HashSet columseditable
      The editable colums.
      protected java.util.Vector data
      The data.
      • Fields inherited from class javax.swing.table.AbstractTableModel

        listenerList
    • Constructor Summary

      Constructors 
      Constructor Description
      ObjectTableModel()
      Create a new object table model.
      ObjectTableModel​(java.lang.String[] colnames)
      Create a new object table model.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addRow​(java.lang.Object[] row, java.lang.Object object)
      Add a row to the model.
      void addRow​(java.lang.Object row, java.lang.Object object)
      Add a row to the model.
      void addRow​(java.util.ArrayList row, java.lang.Object object)
      Add a row to the model.
      java.lang.Class getColumnClass​(int idx)
      Get the class of the column.
      int getColumnCount()  
      java.lang.String getColumnName​(int column)
      Get a column name
      java.lang.Object getObjectForRow​(int rowcnt)
      Get the associated object for a row.
      int getRowCount()  
      java.lang.Object getValueAt​(int row, int column)
      Get the value from a field.
      void insertRow​(int rowcnt, java.lang.Object[] row, java.lang.Object object)
      Insert a row at a position.
      void insertRow​(int rowcnt, java.util.List row, java.lang.Object object)
      Insert a row at a position.
      boolean isCellEditable​(int rowIndex, int columnIndex)
      Returns false.
      void modifyData​(java.lang.Object val, int rowcnt, int columncnt)
      Modify a row at a position.
      void removeAllRows()
      Remove all rows from the model.
      void removeRow​(int cnt)
      Remove a row from the model.
      void removeRow​(java.lang.Object object)
      Remove a row from the model.
      void setColumnClass​(java.lang.Class clazz, int idx)
      Set the class of the column.
      void setColumnEditable​(boolean editable, int col)
      Set if a column is editable.
      • Methods inherited from class javax.swing.table.AbstractTableModel

        addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener, setValueAt
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • columns

        protected java.util.Vector columns
        The data.
      • data

        protected java.util.Vector data
        The data.
      • columnclasses

        protected java.util.HashMap columnclasses
        The classes of the columns.
      • columseditable

        protected java.util.HashSet columseditable
        The editable colums.
    • Constructor Detail

      • ObjectTableModel

        public ObjectTableModel()
        Create a new object table model.
      • ObjectTableModel

        public ObjectTableModel​(java.lang.String[] colnames)
        Create a new object table model.
    • Method Detail

      • addRow

        public void addRow​(java.lang.Object row,
                           java.lang.Object object)
        Add a row to the model.
        Parameters:
        row - The row data.
        object - The associated object.
      • addRow

        public void addRow​(java.util.ArrayList row,
                           java.lang.Object object)
        Add a row to the model.
        Parameters:
        row - The row data.
        object - The associated object.
      • addRow

        public void addRow​(java.lang.Object[] row,
                           java.lang.Object object)
        Add a row to the model.
        Parameters:
        row - The row data.
        object - The associated object.
      • insertRow

        public void insertRow​(int rowcnt,
                              java.lang.Object[] row,
                              java.lang.Object object)
        Insert a row at a position.
        Parameters:
        rowcnt - The row cnt.
        row - The row data.
        object - The object.
      • insertRow

        public void insertRow​(int rowcnt,
                              java.util.List row,
                              java.lang.Object object)
        Insert a row at a position.
        Parameters:
        rowcnt - The row cnt.
        row - The row data.
        object - The object.
      • removeRow

        public void removeRow​(java.lang.Object object)
        Remove a row from the model.
        Parameters:
        object - The associated object.
      • removeRow

        public void removeRow​(int cnt)
        Remove a row from the model.
        Parameters:
        cnt - The row number.
      • removeAllRows

        public void removeAllRows()
        Remove all rows from the model.
      • modifyData

        public void modifyData​(java.lang.Object val,
                               int rowcnt,
                               int columncnt)
        Modify a row at a position.
        Parameters:
        val - The value.
        rowcnt - The row.
        columncnt - The column.
      • getObjectForRow

        public java.lang.Object getObjectForRow​(int rowcnt)
        Get the associated object for a row.
        Parameters:
        rowcnt - The row ccount.
        Returns:
        The object.
      • getColumnName

        public java.lang.String getColumnName​(int column)
        Get a column name
        Specified by:
        getColumnName in interface javax.swing.table.TableModel
        Overrides:
        getColumnName in class javax.swing.table.AbstractTableModel
        Parameters:
        column - The number of the column.
        Returns:
        The column name.
      • getColumnClass

        public java.lang.Class getColumnClass​(int idx)
        Get the class of the column.
        Specified by:
        getColumnClass in interface javax.swing.table.TableModel
        Overrides:
        getColumnClass in class javax.swing.table.AbstractTableModel
        Parameters:
        idx - the column being queried
        Returns:
        the Object.class
      • setColumnClass

        public void setColumnClass​(java.lang.Class clazz,
                                   int idx)
        Set the class of the column.
        Parameters:
        clazz - The class.
        idx - the column being queried
      • setColumnEditable

        public void setColumnEditable​(boolean editable,
                                      int col)
        Set if a column is editable.
        Parameters:
        editable - True, for editable.
        col - The column.
      • isCellEditable

        public boolean isCellEditable​(int rowIndex,
                                      int columnIndex)
        Returns false. This is the default implementation for all cells.
        Specified by:
        isCellEditable in interface javax.swing.table.TableModel
        Overrides:
        isCellEditable in class javax.swing.table.AbstractTableModel
        Parameters:
        rowIndex - the row being queried
        columnIndex - the column being queried
        Returns:
        false
      • getRowCount

        public int getRowCount()
        Returns:
        The row count.
      • getColumnCount

        public int getColumnCount()
        Returns:
        The column count.
      • getValueAt

        public java.lang.Object getValueAt​(int row,
                                           int column)
        Get the value from a field.
        Parameters:
        row - The row index.
        column - The column index.
        Returns:
        The value.