|
Copyright © 2005 Scientific Applications. All Rights Reserved. | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavax.swing.table.AbstractTableModel
com.sciapp.table.ObjectTableModel
public abstract class ObjectTableModel
ObjectTableModel uses an internal ArrayList structure to store the rows of a JTable.
The elements in the list can be any Java object.
Subclasses should implement getValueAt(int, int) and setValueAt(java.lang.Object, int, int), which define
how objects at a column index are retrieved/set respectively.
The column names are specified in the constructor, or with setColumns(java.lang.String[])
| Field Summary | |
|---|---|
protected String[] |
columns
A String array holding the columns of the TableModel |
protected List |
rows
The actual table rows stored in a List. |
protected boolean |
sendReorderEvent
boolean indicating if a reorder event should be sent when needed |
| Fields inherited from class javax.swing.table.AbstractTableModel |
|---|
listenerList |
| Constructor Summary | |
|---|---|
ObjectTableModel(String[] columns)
Constructs an ObjectTableModel with columns as the table columns. |
|
| Method Summary | |
|---|---|
void |
addReorderListener(ReorderListener l)
Adds a ReorderListener that is notified each time a change to the data model occurs so that the table updates the selected rows accordingly. |
void |
addRow(Object o)
Adds a row to the end of the model. |
void |
addRows(List addedRows)
Adds a list of rows to the end of the model. |
void |
clear()
Clears the model of any data. |
void |
fireRowsMapped(int[] changedIndices)
Notifies listeners that the rows of the table have been reordered according to the changedIndices map. |
void |
fireRowsReordered(ReorderEvent e)
Notifies listeners that the rows of the table have been reordered in some way. |
Object |
getCellValue(Object o,
int index)
Returns the Object found at index of row passed as a parameter. |
Class |
getColumnClass(int c)
Returns the class of the object at column c. |
int |
getColumnCount()
Returns the number of columns in the model. |
String |
getColumnName(int column)
Returns the name of the column at column, which depends
on the String array passed in the constructor. |
String[] |
getColumns()
Returns a clone of the String array of table column names. |
int |
getRowCount()
Returns the number of rows in the model. |
List |
getRows()
Returns the data of this tablemodel |
boolean |
getSendReorderEvent()
Determines if a reorder event should be sent when needed. |
Object |
getValueAt(int rowIndex,
int columnIndex)
Returns the value for the cell at columnIndex and
rowIndex. |
abstract Object |
getValueAt(Object o,
int index)
Returns the value for the object o at index. |
void |
insertRow(int row,
Object o)
Inserts a row at row in the model. |
void |
insertRows(int row,
List insertedRows)
Inserts a list of rows at row in the model. |
boolean |
isCellEditable(int rowIndex,
int columnIndex)
Returns true by default. |
void |
removeReorderListener(ReorderListener l)
Removes a listener from the list that is notified each time a reorder event is generated. |
void |
removeRow(int row)
Removes a row from the data model |
void |
removeRows(int[] deletedRows)
Removes a few rows from the data model |
void |
setColumns(String[] columns)
Sets the table columns. |
void |
setRows(List rows)
Assigns the 'row' data. |
void |
setSendReorderEvent(boolean sendReorderEvent)
Determines if a reorder event should be sent when needed. |
void |
setValueAt(Object aValue,
int rowIndex,
int columnIndex)
Assigns aValue to the object at columnIndex and rowIndex. |
abstract void |
setValueAt(Object o,
Object aValue,
int index)
Sets the value of Object o at index to aValue |
| Methods inherited from class javax.swing.table.AbstractTableModel |
|---|
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.sciapp.table.ListTableModel |
|---|
fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged |
| Methods inherited from interface javax.swing.table.TableModel |
|---|
addTableModelListener, removeTableModelListener |
| Field Detail |
|---|
protected List rows
protected String[] columns
protected boolean sendReorderEvent
| Constructor Detail |
|---|
public ObjectTableModel(String[] columns)
columns as the table columns.
| Method Detail |
|---|
public void addReorderListener(ReorderListener l)
addReorderListener in interface ReorderModell - the ReorderListenerpublic void addRow(Object o)
addRow in interface ListTableModelo - the row being addedpublic void addRows(List addedRows)
addedRows contains objects representing the actual rows being added. e.g. java.util.Vector, for DefaultTableModel.
addRows in interface ListTableModeladdedRows - the rows being added.public void clear()
clear in interface ListTableModelpublic void fireRowsMapped(int[] changedIndices)
fireRowsMapped in interface ReorderModelchangedIndices - int array indicating how the rows have been reordered.ReorderEventpublic void fireRowsReordered(ReorderEvent e)
fireRowsReordered in interface ReorderModele - the reorder event.ReorderEvent
public Object getCellValue(Object o,
int index)
getCellValue in interface ListTableModelo - the row dataindex - an index
public Class getColumnClass(int c)
getColumnClass in interface TableModelgetColumnClass in class AbstractTableModelc - the column
public int getColumnCount()
JTable uses this method to determine how many columns it
should create and display by default.
getColumnCount in interface TableModelTableModel.getRowCount()public String getColumnName(int column)
column, which depends
on the String array passed in the constructor.
getColumnName in interface TableModelgetColumnName in class AbstractTableModelcolumn - the column being queried
column.public String[] getColumns()
public int getRowCount()
JTable uses this method to determine how many rows it
should display. This method should be quick, as it
is called frequently during rendering.
getRowCount in interface TableModelTableModel.getColumnCount()public List getRows()
getRows in interface ListTableModelpublic boolean getSendReorderEvent()
public Object getValueAt(int rowIndex,
int columnIndex)
columnIndex and
rowIndex.
getValueAt in interface TableModelrowIndex - the row whose value is to be queriedcolumnIndex - the column whose value is to be queried
public abstract Object getValueAt(Object o,
int index)
o - the object whose value is to be queriedindex - the column whose value is to be queried
public void insertRow(int row,
Object o)
row in the model.
row - the row index of the row to be insertedo - the row being added
public void insertRows(int row,
List insertedRows)
row in the model.
addedRows contains objects representing the actual rows being added.
e.g. java.util.Vector, for DefaultTableModel.
row - the row index of the rows to be insertedinsertedRows - the rows being inserted.
public boolean isCellEditable(int rowIndex,
int columnIndex)
isCellEditable in interface TableModelisCellEditable in class AbstractTableModelrowIndex - the row being queriedcolumnIndex - the column being queried
TableModel.setValueAt(java.lang.Object, int, int)public void removeReorderListener(ReorderListener l)
removeReorderListener in interface ReorderModell - the RearrangeListenerpublic void removeRow(int row)
removeRow in interface ListTableModelrow - the index of the row being removedpublic void removeRows(int[] deletedRows)
removeRows in interface ListTableModeldeletedRows - an integer array that contains indexes of the rows being deletedpublic void setColumns(String[] columns)
columns - the table columns as an array of Stringspublic void setSendReorderEvent(boolean sendReorderEvent)
sendReorderEvent - true if a reorder event should be sent, false otherwise.
public void setValueAt(Object aValue,
int rowIndex,
int columnIndex)
aValue to the object at columnIndex and rowIndex.
setValueAt in interface TableModelsetValueAt in class AbstractTableModelaValue - value to assign to the cellrowIndex - row of the cellcolumnIndex - column of the cellTableModel.getValueAt(int, int),
TableModel.isCellEditable(int, int)
public abstract void setValueAt(Object o,
Object aValue,
int index)
o - the object whose value is to be changedaValue - the new valueindex - the index whose value is to be changedpublic void setRows(List rows)
rows - the row data to assign
|
Copyright © 2005 Scientific Applications. All Rights Reserved. | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||