|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object![]()
![]()
![]()
javax.swing.table.AbstractTableModel
![]()
![]()
![]()
javax.swing.table.DefaultTableModel
, TableModel

public class DefaultTableModel


This is an implementation of TableModel that
uses a Vector of Vectors to store the
cell value objects.
Warning:
Serialized objects of this class will not be compatible with
future Swing releases. The current serialization support is
appropriate for short term storage or RMI between applications running
the same version of Swing. As of 1.4, support for long term storage
of all JavaBeansTM
has been added to the java.beans package.
Please see XMLEncoder
.
TableModel
,
getDataVector()
,
Serialized Form| Field Summary | |
|---|---|
protected Vector |
columnIdentifiers
The Vector of column identifiers. |
protected Vector |
dataVector
The Vector of Vectors of
Object values. |
Fields inherited from class javax.swing.table.AbstractTableModel ![]() |
|---|
listenerList |
| Constructor Summary | |
|---|---|
DefaultTableModel
Constructs a default DefaultTableModel
which is a table of zero columns and zero rows. |
|
DefaultTableModel
Constructs a DefaultTableModel with
rowCount and columnCount of
null object values. |
|
DefaultTableModel
Constructs a DefaultTableModel and initializes the table
by passing data and columnNames
to the setDataVector
method. |
|
DefaultTableModel
Constructs a DefaultTableModel with as many
columns as there are elements in columnNames
and rowCount of null
object values. |
|
DefaultTableModel
Constructs a DefaultTableModel with as many columns
as there are elements in columnNames
and rowCount of null
object values. |
|
DefaultTableModel
Constructs a DefaultTableModel and initializes the table
by passing data and columnNames
to the setDataVector method. |
|
| Method Summary | |
|---|---|
void |
addColumn
Adds a column to the model. |
void |
addColumn
Adds a column to the model. |
void |
addColumn
Adds a column to the model. |
void |
addRow
Adds a row to the end of the model. |
void |
addRow
Adds a row to the end of the model. |
protected static Vector |
convertToVector
Returns a vector that contains the same objects as the array. |
protected static Vector |
convertToVector
Returns a vector of vectors that contains the same objects as the array. |
int |
getColumnCount
Returns the number of columns in this data table. |
String |
getColumnName
Returns the column name. |
Vector |
getDataVector
Returns the Vector of Vectors
that contains the table's
data values. |
int |
getRowCount
Returns the number of rows in this data table. |
Object |
getValueAt
Returns an attribute value for the cell at row
and column. |
void |
insertRow
Inserts a row at row in the model. |
void |
insertRow
Inserts a row at row in the model. |
boolean |
isCellEditable
Returns true regardless of parameter values. |
void |
moveRow
Moves one or more rows from the inclusive range start to
end to the to position in the model. |
void |
newDataAvailable
Equivalent to fireTableChanged. |
void |
newRowsAdded
Ensures that the new rows have the correct number of columns. |
void |
removeRow
Removes the row at row from the model. |
void |
rowsRemoved
Equivalent to fireTableChanged. |
void |
setColumnCount
Sets the number of columns in the model. |
void |
setColumnIdentifiers
Replaces the column identifiers in the model. |
void |
setColumnIdentifiers
Replaces the column identifiers in the model. |
void |
setDataVector
Replaces the value in the dataVector instance
variable with the values in the array dataVector. |
void |
setDataVector
Replaces the current dataVector instance variable
with the new Vector of rows, dataVector. |
void |
setNumRows
Obsolete as of Java 2 platform v1.3. |
void |
setRowCount
Sets the number of rows in the model. |
void |
setValueAt
Sets the object value for the cell at column and
row. |
Methods inherited from class javax.swing.table.AbstractTableModel ![]() |
|---|
addTableModelListener |
Methods inherited from class java.lang.Object ![]() |
|---|
clone |
| Field Detail |
|---|

protected Vector![]()
![]()
dataVector
Vector of Vectors of
Object values.

protected Vector![]()
![]()
columnIdentifiers
Vector of column identifiers.
| Constructor Detail |
|---|

public DefaultTableModel()
DefaultTableModel
which is a table of zero columns and zero rows.

public DefaultTableModel(int rowCount,
int columnCount)
DefaultTableModel with
rowCount and columnCount of
null object values.
rowCount - the number of rows the table holdscolumnCount - the number of columns the table holdssetValueAt(java.lang.Object, int, int)


public DefaultTableModel(Vector![]()
![]()
columnNames, int rowCount)
DefaultTableModel with as many columns
as there are elements in columnNames
and rowCount of null
object values. Each column's name will be taken from
the columnNames vector.
columnNames - vector containing the names
of the new columns; if this is
null then the model has no columnsrowCount - the number of rows the table holdssetDataVector(java.util.Vector, java.util.Vector)
,
setValueAt(java.lang.Object, int, int)


public DefaultTableModel(Object![]()
![]()
[] columnNames, int rowCount)
DefaultTableModel with as many
columns as there are elements in columnNames
and rowCount of null
object values. Each column's name will be taken from
the columnNames array.
columnNames - array containing the names
of the new columns; if this is
null then the model has no columnsrowCount - the number of rows the table holdssetDataVector(java.util.Vector, java.util.Vector)
,
setValueAt(java.lang.Object, int, int)


public DefaultTableModel(Vector![]()
![]()
data, Vector
![]()
![]()
columnNames)
DefaultTableModel and initializes the table
by passing data and columnNames
to the setDataVector method.
data - the data of the table, a Vector
of Vectors of Object
valuescolumnNames - vector containing the names
of the new columnsgetDataVector()
,
setDataVector(java.util.Vector, java.util.Vector)


public DefaultTableModel(Object![]()
![]()
[][] data, Object
![]()
![]()
[] columnNames)
DefaultTableModel and initializes the table
by passing data and columnNames
to the setDataVector
method. The first index in the Object[][] array is
the row index and the second is the column index.
data - the data of the tablecolumnNames - the names of the columnsgetDataVector()
,
setDataVector(java.util.Vector, java.util.Vector)

| Method Detail |
|---|

public Vector![]()
![]()
getDataVector()
Vector of Vectors
that contains the table's
data values. The vectors contained in the outer vector are
each a single row of values. In other words, to get to the cell
at row 1, column 5:
((Vector)getDataVector().elementAt(1)).elementAt(5);
newDataAvailable(javax.swing.event.TableModelEvent)
,
newRowsAdded(javax.swing.event.TableModelEvent)
,
setDataVector(java.util.Vector, java.util.Vector)


public void setDataVector(Vector![]()
![]()
dataVector, Vector
![]()
![]()
columnIdentifiers)
dataVector instance variable
with the new Vector of rows, dataVector.
Each row is represented in dataVector as a
Vector of Object values.
columnIdentifiers are the names of the new
columns. The first name in columnIdentifiers is
mapped to column 0 in dataVector. Each row in
dataVector is adjusted to match the number of
columns in columnIdentifiers
either by truncating the Vector if it is too long,
or adding null values if it is too short.
Note that passing in a null value for
dataVector results in unspecified behavior,
an possibly an exception.
dataVector - the new data vectorcolumnIdentifiers - the names of the columnsgetDataVector()


public void setDataVector(Object![]()
![]()
[][] dataVector, Object
![]()
![]()
[] columnIdentifiers)
dataVector instance
variable with the values in the array dataVector.
The first index in the Object[][]
array is the row index and the second is the column index.
columnIdentifiers are t