com.darwinsys.swingui
Class ArrayListTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by com.darwinsys.swingui.ArrayListTableModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel

public abstract class ArrayListTableModel
extends javax.swing.table.AbstractTableModel

JTable model for List of heterogeneous objects. Subclasses must set String columnNames[] and Class columnClasses[], which MUST be in the same order. Subclasses need only implement these AbstractTableModel methods:

 public int getColumnCount() {
 public Object getValueAt(int row, int col)  {
 public void setValueAt(Object val, int row, int col)  {
 

See Also:
Serialized Form

Field Summary
protected  java.lang.Class[] columnClasses
          List of column names, must be provided by subclass.
protected  java.lang.String[] columnNames
          List of column names, must be provided by subclass.
protected  java.util.List methods
          The list of Method object
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
ArrayListTableModel(java.util.List m)
          Constructor requires the list of objects
 
Method Summary
 java.lang.Object getCached(int row)
          Cache one most-recently-used item.
 java.lang.Class<?> getColumnClass(int n)
          Get the class of a given column, from the list provided by subclass
 java.lang.String getColumnName(int n)
          Get the name of a given column, from the list provided by subclass
 int getRowCount()
          Returns the number of objects in the list.
 void invalidateCache()
          Invalidate the cache.
 boolean isCellEditable(int rowIndex, int columnIndex)
          All cells are 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
 
Methods inherited from interface javax.swing.table.TableModel
getColumnCount, getValueAt
 

Field Detail

columnNames

protected java.lang.String[] columnNames
List of column names, must be provided by subclass.


columnClasses

protected java.lang.Class[] columnClasses
List of column names, must be provided by subclass.


methods

protected java.util.List methods
The list of Method object

Constructor Detail

ArrayListTableModel

public ArrayListTableModel(java.util.List m)
Constructor requires the list of objects

Method Detail

getColumnName

public java.lang.String getColumnName(int n)
Get the name of a given column, from the list provided by subclass

Specified by:
getColumnName in interface javax.swing.table.TableModel
Overrides:
getColumnName in class javax.swing.table.AbstractTableModel

getColumnClass

public java.lang.Class<?> getColumnClass(int n)
Get the class of a given column, from the list provided by subclass

Specified by:
getColumnClass in interface javax.swing.table.TableModel
Overrides:
getColumnClass in class javax.swing.table.AbstractTableModel

getRowCount

public int getRowCount()
Returns the number of objects in the list.


isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)
All cells are editable. Subclasses can override this if only some cells should be editable.

Specified by:
isCellEditable in interface javax.swing.table.TableModel
Overrides:
isCellEditable in class javax.swing.table.AbstractTableModel

getCached

public java.lang.Object getCached(int row)
Cache one most-recently-used item. This is a convenience routine that subclasses are invited but not required to use. Normal use would be, in get/setValueAt():
                public void setValueAt(int row, ...) {
                        MyDataType current = (MyDataType) getCached(row);
                        ...
                }
 


invalidateCache

public void invalidateCache()
Invalidate the cache. Called automatically by setListData(); must be called if you otherwise change the ArrayList.



Copyright © 1996-2004 Ian F. Darwin. See license.html for usage license.