TableModel that
uses a Vector of Vectors to store the
cell value objects.Warning
DefaultTableModel returns a
column class of Object. When
DefaultTableModel is used with a
TableRowSorter this will result in extensive use of
toString, which for non-String data types
is expensive. If you use DefaultTableModel with a
TableRowSorter you are strongly encouraged to override
getColumnClass to return the appropriate type.
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 JavaBeans
has been added to the java.beans package.
Please see java..
TableModel, getDataVector
| Modifier and Type | Field and Description |
|---|---|
| protected Vector | columnIdentifiers
The |
| protected Vector | dataVector
The |
| Access | Constructor and Description |
|---|---|
| public | DefaultTableModel()
Constructs a default |
| public | DefaultTableModel(int
the number of rows the table holds rowCount, int the number of columns the table holds columnCount)Constructs a |
| public | DefaultTableModel(Vector<?>
vector containing the names
of the new columns; if this is
null then the model has no columnsthe number of rows the table holds rowCount)Constructs a |
| public | DefaultTableModel(Object[]
array containing the names
of the new columns; if this is
null then the model has no columnsthe number of rows the table holds rowCount)Constructs a |
| public | DefaultTableModel(Vector<? extends Vector<E>>
the data of the table, a data, Vector<?> Vector
of Vectors of Object
valuesvector containing the names
of the new columnsConstructs a |
| public | DefaultTableModel(Object[][]
the data of the table data, Object[] the names of the columns columnNames)Constructs a |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| protected static Vector | Returns: the new vector; ifanArray is null,
returns nullthe array to be converted anArray)Returns a vector that contains the same objects as the array. |
| protected static Vector | Returns: the new vector of vectors; ifanArray is
null, returns nullthe double array to be converted anArray)Returns a vector of vectors that contains the same objects as the array. |
| private static int | |
| public int | Returns: the number of columns in the modelImplements javax. Returns the number of columns in this data table. |
| public String | Returns: a name for this column using the string value of the appropriate member incolumnIdentifiers.
If columnIdentifiers does not have an entry
for this index, returns the default
name provided by the superclass.Overrides javax. Implements javax. Returns the column name. |
| public Vector | Returns: the vector of vectors containing the tables data valuesReturns the |
| public int | Returns: the number of rows in the modelImplements javax. Returns the number of rows in this data table. |
| public Object | Returns: the value Object at the specified cellthe row whose value is to be queried row, int the column whose value is to be queried column)Implements javax. Returns an attribute value for the cell at |
| public void | |
| public void | |
| public boolean | Returns: truethe row whose value is to be queried row, int the column whose value is to be queried column)Overrides javax. Implements javax. Returns true regardless of parameter values. |
| private void | |
| public void | moveRow(int
the starting row index to be moved start, int the ending row index to be moved end, int the destination of the rows to be moved to)Moves one or more rows from the inclusive range |
| public void | |
| public void | newRowsAdded(TableModelEvent
this e)TableModelEvent describes
where the rows were added.
If null it assumes
all the rows were newly addedEnsures that the new rows have the correct number of columns. |
| private static <E> Vector | |
| private static <E> Vector | |
| public void | |
| private static <E> void | |
| public void | |
| public void | setColumnCount(int
the new number of columns in the model columnCount)Sets the number of columns in the model. |
| public void | setColumnIdentifiers(Vector<?>
vector of column identifiers. If
columnIdentifiers)null, set the model
to zero columnsReplaces the column identifiers in the model. |
| public void | setColumnIdentifiers(Object[]
array of column identifiers.
If newIdentifiers)null, set
the model to zero columnsReplaces the column identifiers in the model. |
| public void | setDataVector(Vector<? extends Vector<E>>
the new data vector dataVector, Vector<?> the names of the columns columnIdentifiers)Replaces the current |
| public void | setDataVector(Object[][]
the new data vector dataVector, Object[] the names of the columns columnIdentifiers)Replaces the value in the |
| public void | |
| public void | |
| public void | setValueAt(Object
the new value; this can be null aValue, int the row whose value is to be changed row, int the column whose value is to be changed column)Overrides javax. Implements javax. Sets the object value for the cell at |
| columnIdentifiers | back to summary |
|---|---|
| protected Vector<E> columnIdentifiers The
| |
| dataVector | back to summary |
|---|---|
| protected Vector<Vector<E>> dataVector The
| |
| DefaultTableModel | back to summary |
|---|---|
| public DefaultTableModel() Constructs a default | |
| DefaultTableModel | back to summary |
|---|---|
| public DefaultTableModel(int rowCount, int columnCount) Constructs a
| |
| DefaultTableModel | back to summary |
|---|---|
| public DefaultTableModel(Vector<?> columnNames, int rowCount) Constructs a
| |
| DefaultTableModel | back to summary |
|---|---|
| public DefaultTableModel(Object[] columnNames, int rowCount) Constructs a
| |
| DefaultTableModel | back to summary |
|---|---|
| public DefaultTableModel(Vector<? extends Vector<E>> data, Vector<?> columnNames) Constructs a
| |
| DefaultTableModel | back to summary |
|---|---|
| public DefaultTableModel(Object[][] data, Object[] columnNames) Constructs a
| |
| addColumn | back to summary |
|---|---|
| public void addColumn(Object columnName) Adds a column to the model. The new column will have the
identifier
| |
| addColumn | back to summary |
|---|---|
| public void addColumn(Object columnName, Vector<?> columnData) Adds a column to the model. The new column will have the
identifier
| |
| addColumn | back to summary |
|---|---|
| public void addColumn(Object columnName, Object[] columnData) Adds a column to the model. The new column will have the
identifier
| |
| addRow | back to summary |
|---|---|
| public void addRow(Vector<?> rowData) Adds a row to the end of the model. The new row will contain
| |
| addRow | back to summary |
|---|---|
| public void addRow(Object[] rowData) Adds a row to the end of the model. The new row will contain
| |
| convertToVector | back to summary |
|---|---|
| protected static Vector Returns a vector that contains the same objects as the array. | |
| convertToVector | back to summary |
|---|---|
| protected static Vector Returns a vector of vectors that contains the same objects as the array. | |
| gcd | back to summary |
|---|---|
| private static int gcd(int i, int j) | |
| getColumnCount | back to summary |
|---|---|
| public int getColumnCount() Implements javax. Returns the number of columns in this data table.
| |
| getColumnName | back to summary |
|---|---|
| public String getColumnName(int column) Overrides javax. Implements javax. Returns the column name.
| |
| getDataVector | back to summary |
|---|---|
| public Vector Returns the
| |
| getRowCount | back to summary |
|---|---|
| public int getRowCount() Implements javax. Returns the number of rows in this data table.
| |
| getValueAt | back to summary |
|---|---|
| public Object getValueAt(int row, int column) Implements javax. Returns an attribute value for the cell at
| |
| insertRow | back to summary |
|---|---|
| public void insertRow(int row, Vector<?> rowData) Inserts a row at
| |
| insertRow | back to summary |
|---|---|
| public void insertRow(int row, Object[] rowData) Inserts a row at
| |
| isCellEditable | back to summary |
|---|---|
| public boolean isCellEditable(int row, int column) Overrides javax. Implements javax. Returns true regardless of parameter values.
| |
| justifyRows | back to summary |
|---|---|
| private void justifyRows(int from, int to) | |
| moveRow | back to summary |
|---|---|
| public void moveRow(int start, int end, int to) Moves one or more rows from the inclusive range
Examples of moves:
1. moveRow(1,3,5);
a|B|C|D|e|f|g|h|i|j|k - before
a|e|f|g|h|B|C|D|i|j|k - after
2. moveRow(6,7,1);
a|b|c|d|e|f|G|H|i|j|k - before
a|G|H|b|c|d|e|f|i|j|k - after
| |
| newDataAvailable | back to summary |
|---|---|
| public void newDataAvailable(TableModelEvent event) Equivalent to
| |
| newRowsAdded | back to summary |
|---|---|
| public void newRowsAdded(TableModelEvent e) Ensures that the new rows have the correct number of columns.
This is accomplished by using the
| |
| newVector | back to summary |
|---|---|
| private static <E> Vector | |
| nonNullVector | back to summary |
|---|---|
| private static <E> Vector | |
| removeRow | back to summary |
|---|---|
| public void removeRow(int row) Removes the row at
| |
| rotate | back to summary |
|---|---|
| private static <E> void rotate(Vector<E> v, int a, int b, int shift) | |
| rowsRemoved | back to summary |
|---|---|
| public void rowsRemoved(TableModelEvent event) Equivalent to
| |
| setColumnCount | back to summary |
|---|---|
| public void setColumnCount(int columnCount) Sets the number of columns in the model. If the new size is greater
than the current size, new columns are added to the end of the model
with
| |
| setColumnIdentifiers | back to summary |
|---|---|
| public void setColumnIdentifiers(Vector<?> columnIdentifiers) Replaces the column identifiers in the model. If the number of
| |
| setColumnIdentifiers | back to summary |
|---|---|
| public void setColumnIdentifiers(Object[] newIdentifiers) Replaces the column identifiers in the model. If the number of
| |
| setDataVector | back to summary |
|---|---|
| public void setDataVector(Vector<? extends Vector<E>> dataVector, Vector<?> columnIdentifiers) Replaces the current Note that passing in a
| |
| setDataVector | back to summary |
|---|---|
| public void setDataVector(Object[][] dataVector, Object[] columnIdentifiers) Replaces the value in the
| |
| setNumRows | back to summary |
|---|---|
| public void setNumRows(int rowCount) Obsolete as of Java 2 platform v1.3. Please use
| |
| setRowCount | back to summary |
|---|---|
| public void setRowCount(int rowCount) Sets the number of rows in the model. If the new size is greater
than the current size, new rows are added to the end of the model
If the new size is less than the current size, all
rows at index
| |
| setValueAt | back to summary |
|---|---|
| public void setValueAt(Object aValue, int row, int column) Overrides javax. Implements javax. Sets the object value for the cell at
| |