javax.swing.table
Class DefaultTableModeljava.lang.Object | +--javax.swing.table.AbstractTableModel | +--javax.swing.table.DefaultTableModel
- All Implemented Interfaces:
- Serializable, TableModel
- public class DefaultTableModel
- extends AbstractTableModel
- implements Serializable
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.
- See Also:
- TableModel, getDataVector()
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(int rowCount, int columnCount)
Constructs a DefaultTableModel with rowCount and columnCount of null object values.DefaultTableModel(Object[][] data, Object[] columnNames)
Constructs a DefaultTableModel and initializes the table by passing data and columnNames to the setDataVector method.DefaultTableModel(Object[] columnNames, int rowCount)
Constructs a DefaultTableModel with as many columns as there are elements in columnNames and rowCount of null object values.DefaultTableModel(Vector columnNames, int rowCount)
Constructs a DefaultTableModel with as many columns as there are elements in columnNames and rowCount of null object values.DefaultTableModel(Vector data, Vector columnNames)
Constructs a DefaultTableModel and initializes the table by passing data and columnNames to the setDataVector method.
Method Summary
void addColumn(Object columnName)
Adds a column to the model.void addColumn(Object columnName, Object[] columnData)
Adds a column to the model.void addColumn(Object columnName, Vector columnData)
Adds a column to the model.void addRow(Object[] rowData)
Adds a row to the end of the model.void addRow(Vector rowData)
Adds a row to the end of the model.protected static Vector convertToVector(Object[] anArray)
Returns a vector that contains the same objects as the array.protected static Vector convertToVector(Object[][] anArray)
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(int column)
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(int row, int column)
Returns an attribute value for the cell at row and column.void insertRow(int row, Object[] rowData)
Inserts a row at row in the model.void insertRow(int row, Vector rowData)
Inserts a row at row in the model.boolean isCellEditable(int row, int column)
Returns true regardless of parameter values.void moveRow(int start, int end, int to)
Moves one or more rows from the inlcusive range start to end to the to position in the model.void newDataAvailable(TableModelEvent event)
Equivalent to fireTableChanged.void newRowsAdded(TableModelEvent e)
Ensures that the new rows have the correct number of columns.void removeRow(int row)
Removes the row at row from the model.void rowsRemoved(TableModelEvent event)
Equivalent to fireTableChanged.void setColumnCount(int columnCount)
Sets the number of columns in the model.void setColumnIdentifiers(Object[] newIdentifiers)
Replaces the column identifiers in the model.void setColumnIdentifiers(Vector columnIdentifiers)
Replaces the column identifiers in the model.void setDataVector(Object[][] dataVector, Object[] columnIdentifiers)
Replaces the value in the dataVector instance variable with the values in the array dataVector.void setDataVector(Vector dataVector, Vector columnIdentifiers)
Replaces the current dataVector instance variable with the new Vector of rows, dataVector.void setNumRows(int rowCount)
Obsolete as of Java 2 platform v1.3.void setRowCount(int rowCount)
Sets the number of rows in the model.void setValueAt(Object aValue, int row, int column)
Sets the object value for the cell at column and row.
Methods inherited from class javax.swing.table.AbstractTableModel addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated,