java.lang.Object
javax.swing.table.AbstractTableModel
ledestin.swing.CollectionTableModel
- All Implemented Interfaces:
- java.io.Serializable, javax.swing.table.TableModel
- public class CollectionTableModel
- extends javax.swing.table.AbstractTableModel
Allows to show a Collection in a JEditableTable. It wraps your data source
Collection that allows it to be shown in a table. There is always one column and
getValueAt() always returns appropriate Collection item (should have toString()
implemented).
If you'd like to change this behavior you'll have to implement the following
methods:
public int getColumnCount();
public Object getValueAt(int row, int column);
| Methods inherited from class javax.swing.table.AbstractTableModel |
addTableModelListener, findColumn, fireTableCellUpdated, fireTableRowsUpdated, getColumnClass, getColumnName, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAt |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ds
protected java.util.Collection ds
rowClass
protected java.lang.Class rowClass
dataChanged
protected boolean dataChanged
data
private java.lang.Object[] data
CollectionTableModel
public CollectionTableModel(java.util.Collection ds)
throws java.lang.IllegalArgumentException
CollectionTableModel
public CollectionTableModel(java.util.Collection ds,
java.lang.Class rowClass)
throws java.lang.IllegalArgumentException
getRowCount
public int getRowCount()
- Description copied from interface:
javax.swing.table.TableModel
- Returns the number of rows in the model.
getDataSource
public java.util.Collection getDataSource()
setDataSource
public void setDataSource(java.util.Collection ds)
createNewRow
public java.lang.Object createNewRow()
throws java.lang.InstantiationException
- Creates a new object/row for the table model. The faculty is wanted for
JEditableTable's ability to add rows to a table. When request for inserting
comes to the table it shows a dialog for editing a new object.
getData
protected java.lang.Object[] getData()
getValueAt
public java.lang.Object getValueAt(int row,
int column)
- Returns an object representing row in a table, i.e. always return the same
object for any column given. Descendants will have to redefine this behaviour
if necessary, for example, returning ((SampleObject)o).col1() for 1st column
and col2() for the second.
getColumnCount
public int getColumnCount()
- Description copied from interface:
javax.swing.table.TableModel
- Returns the number of columns in the model.
fireTableChanged
public void fireTableChanged(javax.swing.event.TableModelEvent e)
- Description copied from class:
javax.swing.table.AbstractTableModel
- Sends the specified event to all registered listeners.
fireTableDataChanged
public void fireTableDataChanged()
- Description copied from class:
javax.swing.table.AbstractTableModel
- Sends a javax.swing.event.TableModelEvent to all registered listeners to inform
them that the table data has changed.
fireTableRowsDeleted
public void fireTableRowsDeleted(int firstRow,
int lastRow)
- Description copied from class:
javax.swing.table.AbstractTableModel
- Sends a javax.swing.event.TableModelEvent to all registered listeners to inform
them that some rows have been deleted from the model.
fireTableRowsInserted
public void fireTableRowsInserted(int firstRow,
int lastRow)
- Description copied from class:
javax.swing.table.AbstractTableModel
- Sends a javax.swing.event.TableModelEvent to all registered listeners to inform
them that some rows have been inserted into the model.
fireTableStructureChanged
public void fireTableStructureChanged()
- Description copied from class:
javax.swing.table.AbstractTableModel
- Sends a javax.swing.event.TableModelEvent to all registered listeners to inform
them that the table structure has changed.