|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.swing.table.AbstractTableModel net.sf.swinglib.table.ExpandingTableModel
public class ExpandingTableModel
A TableModel
that can be resized on the fly, tracks whether
a cell has been changed, and allows the table to add new rows via edits.
The "expanding" behavior is supported by reporting an extra row via
getRowCount()
. Calls to getValueAt(int, int)
for this "phantom" row
return null
, while calls to setValueAt(java.lang.Object, int, int)
make the row
permanent and create a new phantom row.
Field Summary |
---|
Fields inherited from class javax.swing.table.AbstractTableModel |
---|
listenerList |
Constructor Summary | |
---|---|
ExpandingTableModel()
Creates an instance that has no rows and no columns. |
|
ExpandingTableModel(int rows,
int cols)
Creates an instance that is pre-sized to the specified number of rows and columns, with all cells containing null . |
|
ExpandingTableModel(Object[][] data)
Creates an instance that is initialized with the passed data. |
|
ExpandingTableModel(Object[][] data,
Object[] columnNames)
Creates an instance that is initialized with the passed data and column headers. |
|
ExpandingTableModel(Object[][] data,
Object[] columnNames,
Class<?>[] colClasses)
Creates an instance that is initialized with the passed data, column headers, and column classes. |
Method Summary | |
---|---|
Class<?> |
getColumnClass(int col)
Returns the class of the particular column, Object if
no class has been specified for the column. |
int |
getColumnCount()
Returns the current number of columns in the model. |
String |
getColumnName(int col)
Returns the name of the particular column, empty string if a header has not been defined for the column. |
int |
getRowCount()
Returns the number of rows in the model, including the "phantom" row. |
Object |
getValueAt(int row,
int col)
Returns the value at a particular cell in the model. |
boolean |
isCellEditable(int row,
int col)
|
void |
setColumnClass(int col,
Class<?> klass)
Updates the name of a column with the passed value. |
void |
setColumnName(int col,
Object name)
Updates the name for a column with the passed value. |
void |
setValueAt(Object value,
int row,
int col)
Stores the passed value in the specified cell. |
void |
setWidth(int width)
Sets the width (column count) of the model. |
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 |
Constructor Detail |
---|
public ExpandingTableModel()
setWidth(int)
.
public ExpandingTableModel(int rows, int cols)
null
.
public ExpandingTableModel(Object[][] data)
null
.
public ExpandingTableModel(Object[][] data, Object[] columnNames)
Note that headers are defined as arbitrary objects. If the object is mutable, the header value will reflect the string value of the header.
public ExpandingTableModel(Object[][] data, Object[] columnNames, Class<?>[] colClasses)
Object
respectively.
IllegalArgumentException
- if a data element does not correspond
to the class specification.Method Detail |
---|
public int getColumnCount()
setWidth(int)
.
public int getRowCount()
public String getColumnName(int col)
Note that headers may be specified as any type of object, but are
returned as strings. This is no doubt an artifact of the original
implementation using Vector
, but allows the creation
of dynamic headers using mutable objects.
getColumnName
in interface TableModel
getColumnName
in class AbstractTableModel
public Class<?> getColumnClass(int col)
Object
if
no class has been specified for the column.
getColumnClass
in interface TableModel
getColumnClass
in class AbstractTableModel
public Object getValueAt(int row, int col)
null
IndexOutOfBoundsException
- on attempts to get an invalid cell.public void setValueAt(Object value, int row, int col)
setValueAt
in interface TableModel
setValueAt
in class AbstractTableModel
IndexOutOfBoundsException
- on attempts to set an invalid cell.public boolean isCellEditable(int row, int col)
isCellEditable
in interface TableModel
isCellEditable
in class AbstractTableModel
public void setWidth(int width)
null
s on each row if greater.
Header names are not removed when the width is reduced, and will re-appear if the table is subsequently widened.
public void setColumnName(int col, Object name)
public void setColumnClass(int col, Class<?> klass)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |