Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
javax.swing.table.AbstractTableModel
javax.swing.table.DefaultTableModel
Object
instances, usually for display in a JTable
component.
Field Summary | |
protected Vector<T> |
|
protected Vector<T> |
|
Fields inherited from class javax.swing.table.AbstractTableModel | |
listenerList |
Constructor Summary | |
| |
| |
| |
| |
| |
|
Method Summary | |
void | |
void | |
void | |
void |
|
void |
|
protected static Vector<T> |
|
protected static Vector<T> |
|
int |
|
String |
|
Vector<T> |
|
int |
|
Object |
|
void | |
void | |
boolean |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
protected Vector<T> dataVector
Storage for the rows in the table (each row is itself aVector
).
public DefaultTableModel(int numRows, int numColumns)
Creates a new table with the specified number of rows and columns. All cells in the table are initially empty (set tonull
).
- Parameters:
numRows
- the number of rows.numColumns
- the number of columns.
public DefaultTableModel(Object[] columnNames, int numRows)
Creates a new table with the specified column names and row count.
- Parameters:
columnNames
- the column names.numRows
- the number of rows.
public DefaultTableModel(Object[][] data, Object[] columnNames)
Creates a new table with the specified data values and column names.
- Parameters:
data
- the data values.columnNames
- the column names.
public DefaultTableModel(Vector<T> columnNames, int numRows)
Creates a new table with the specified column names and number of rows. The number of columns is determined by the number of column names supplied.
- Parameters:
columnNames
- the column names.numRows
- the number of rows.
public DefaultTableModel(Vector<T> data, Vector<T> columnNames)
Creates a new table with the specified data values and column names.
- Parameters:
data
- the data values.columnNames
- the column names.
public void addColumn(Object columnName)
Adds a column with the specified name to the table. All cell values for the column are initially set tonull
.
- Parameters:
columnName
- the column name (null
permitted).
public void addColumn(Object columnName, Object[] columnData)
Adds a column with the specified name and data values to the table.
- Parameters:
columnName
- the column name (null
permitted).columnData
- the column data.
public void addColumn(Object columnName, Vector<T> columnData)
Adds a column with the specified name and data values to the table.
- Parameters:
columnName
- the column name (null
permitted).columnData
- the column data.
public void addRow(Object[] rowData)
Adds a new row containing the specified data to the table and sends aTableModelEvent
to all registered listeners.
- Parameters:
rowData
- the row data (null
permitted).
public void addRow(Vector<T> rowData)
Adds a new row containing the specified data to the table and sends aTableModelEvent
to all registered listeners.
- Parameters:
rowData
- the row data (null
permitted).
protected static Vector<T> convertToVector(Object[] data)
Converts the data array to aVector
.
- Parameters:
data
- the data array (null
permitted).
- Returns:
- A vector (or
null
if the data array isnull
).
protected static Vector<T> convertToVector(Object[][] data)
Converts the data array to aVector
of rows.
- Parameters:
data
- the data array (null
permitted).
- Returns:
- A vector (or
null
if the data array isnull
.
public int getColumnCount()
Returns the number of columns in the model.
- Specified by:
- getColumnCount in interface TableModel
- Returns:
- The column count.
public String getColumnName(int column)
Get the name of the column. If the column has the column identifier set, the return value is the result of the .toString() method call on that identifier. If the identifier is not explicitly set, the returned value is calculated byAbstractTableModel.getColumnName(int)
.
- Specified by:
- getColumnName in interface TableModel
- Overrides:
- getColumnName in interface AbstractTableModel
- Parameters:
column
- the column index.
- Returns:
- The column name.
public Vector<T> getDataVector()
Returns the vector containing the row data for the table.
- Returns:
- The data vector.
public int getRowCount()
Returns the number of rows in the model.
- Specified by:
- getRowCount in interface TableModel
- Returns:
- The row count.
public Object getValueAt(int row, int column)
Returns the value at the specified cell in the table.
- Specified by:
- getValueAt in interface TableModel
- Parameters:
row
- the row index.column
- the column index.
- Returns:
- The value (
Object
, possiblynull
) at the specified cell in the table.
public void insertRow(int row, Object[] rowData)
Inserts a new row into the table.
- Parameters:
row
- the row index.rowData
- the row data.
public void insertRow(int row, Vector<T> rowData)
Inserts a new row into the table.
- Parameters:
row
- the row index.rowData
- the row data.
public boolean isCellEditable(int row, int column)
Returnstrue
if the specified cell can be modified, andfalse
otherwise. For this implementation, the method always returnstrue
.
- Specified by:
- isCellEditable in interface TableModel
- Overrides:
- isCellEditable in interface AbstractTableModel
- Parameters:
row
- the row index.column
- the column index.
- Returns:
true
in all cases.
public void moveRow(int startIndex, int endIndex, int toIndex)
Moves the rows fromstartIndex
toendIndex
(inclusive) to the specified row.
- Parameters:
startIndex
- the start row.endIndex
- the end row.toIndex
- the row to move to.
public void newDataAvailable(TableModelEvent event)
Sends the specifiedevent
to all registered listeners. This method is equivalent toAbstractTableModel.fireTableChanged(TableModelEvent)
.
- Parameters:
event
- the event.
public void newRowsAdded(TableModelEvent event)
Sends the specifiedevent
to all registered listeners. This method is equivalent toAbstractTableModel.fireTableChanged(TableModelEvent)
.
- Parameters:
event
- the event.
public void removeRow(int row)
Removes a row from the table and sends aTableModelEvent
to all registered listeners.
- Parameters:
row
- the row index.
public void rowsRemoved(TableModelEvent event)
Sends the specifiedevent
to all registered listeners. This method is equivalent toAbstractTableModel.fireTableChanged(TableModelEvent)
.
- Parameters:
event
- the event.
public void setColumnCount(int columnCount)
Sets the number of columns in the table. Existing rows are truncated or padded withnull
values to match the new column count. ATableModelEvent
is sent to all registered listeners.
- Parameters:
columnCount
- the column count.
public void setColumnIdentifiers(Object[] columnIdentifiers)
Sets the column identifiers, updates the data rows (truncating or padding each row withnull
values) to match the number of columns, and sends aTableModelEvent
to all registered listeners.
- Parameters:
columnIdentifiers
- the column identifiers.
public void setColumnIdentifiers(Vector<T> columnIdentifiers)
Sets the column identifiers, updates the data rows (truncating or padding each row withnull
values) to match the number of columns, and sends aTableModelEvent
to all registered listeners.
- Parameters:
columnIdentifiers
- the column identifiers.
public void setDataVector(Object[][] data, Object[] columnNames)
Sets the data and column identifiers for the table.
- Parameters:
data
- the data for the table.columnNames
- the column names.
- Throws:
NullPointerException
- if either argument isnull
.
public void setDataVector(Vector<T> data, Vector<T> columnNames)
Sets the data and column identifiers for the table. The data vector contains aVector
for each row in the table - if the number of objects in each row does not match the number of column names specified, the row data is truncated or expanded (by addingnull
values) as required.
- Parameters:
data
- the data for the table (a vector of row vectors).columnNames
- the column names.
- Throws:
NullPointerException
- if either argument isnull
.
public void setNumRows(int numRows)
This method is obsolete, usesetRowCount(int)
instead.
- Parameters:
numRows
- the number of rows.
public void setRowCount(int rowCount)
Sets the number of rows in the table. IfrowCount
is less than the current number of rows in the table, rows are discarded. IfrowCount
is greater than the current number of rows in the table, new (empty) rows are added.
- Parameters:
rowCount
- the row count.
public void setValueAt(Object value, int row, int column)
Sets the value for the specified cell in the table and sends aTableModelEvent
to all registered listeners.
- Specified by:
- setValueAt in interface TableModel
- Overrides:
- setValueAt in interface AbstractTableModel
- Parameters:
value
- the value (Object
,null
permitted).row
- the row index.column
- the column index.