javax.swing.table
Class DefaultTableModel
- Serializable, TableModel
A two dimensional data structure used to store Object
instances, usually for display in a JTable
component.
void | addColumn(Object columnName) - Adds a column with the specified name to the table.
|
void | addColumn(Object columnName, Object[] columnData) - Adds a column with the specified name and data values to the table.
|
void | addColumn(Object columnName, Vector<T> columnData) - Adds a column with the specified name and data values to the table.
|
void | addRow(Object[] rowData) - Adds a new row containing the specified data to the table and sends a
TableModelEvent to all registered listeners.
|
void | addRow(Vector<T> rowData) - Adds a new row containing the specified data to the table and sends a
TableModelEvent to all registered listeners.
|
protected static Vector<T> | convertToVector(Object[] data) - Converts the data array to a
Vector .
|
protected static Vector<T> | convertToVector(Object[][] data) - Converts the data array to a
Vector of rows.
|
int | getColumnCount() - Returns the number of columns in the model.
|
String | getColumnName(int column) - Get the name of the column.
|
Vector<T> | getDataVector() - Returns the vector containing the row data for the table.
|
int | getRowCount() - Returns the number of rows in the model.
|
Object | getValueAt(int row, int column) - Returns the value at the specified cell in the table.
|
void | insertRow(int row, Object[] rowData) - Inserts a new row into the table.
|
void | insertRow(int row, Vector<T> rowData) - Inserts a new row into the table.
|
boolean | isCellEditable(int row, int column) - Returns
true if the specified cell can be modified, and
false otherwise.
|
void | moveRow(int startIndex, int endIndex, int toIndex) - Moves the rows from
startIndex to endIndex
(inclusive) to the specified row.
|
void | newDataAvailable(TableModelEvent event) - Sends the specified
event to all registered listeners.
|
void | newRowsAdded(TableModelEvent event) - Sends the specified
event to all registered listeners.
|
void | removeRow(int row) - Removes a row from the table and sends a
TableModelEvent to
all registered listeners.
|
void | rowsRemoved(TableModelEvent event) - Sends the specified
event to all registered listeners.
|
void | setColumnCount(int columnCount) - Sets the number of columns in the table.
|
void | setColumnIdentifiers(Object[] columnIdentifiers) - Sets the column identifiers, updates the data rows (truncating
or padding each row with
null values) to match the
number of columns, and sends a TableModelEvent to all
registered listeners.
|
void | setColumnIdentifiers(Vector<T> columnIdentifiers) - Sets the column identifiers, updates the data rows (truncating
or padding each row with
null values) to match the
number of columns, and sends a TableModelEvent to all
registered listeners.
|
void | setDataVector(Object[][] data, Object[] columnNames) - Sets the data and column identifiers for the table.
|
void | setDataVector(Vector<T> data, Vector<T> columnNames) - Sets the data and column identifiers for the table.
|
void | setNumRows(int numRows) - This method is obsolete, use
setRowCount(int) instead.
|
void | setRowCount(int rowCount) - Sets the number of rows in the table.
|
void | setValueAt(Object value, int row, int column) - Sets the value for the specified cell in the table and sends a
TableModelEvent to all registered listeners.
|
addTableModelListener , extends EventListener> T[] getListeners , findColumn , fireTableCellUpdated , fireTableChanged , fireTableDataChanged , fireTableRowsDeleted , fireTableRowsInserted , fireTableRowsUpdated , fireTableStructureChanged , getColumnClass , getColumnName , getTableModelListeners , isCellEditable , removeTableModelListener , setValueAt |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
dataVector
protected Vector<T> dataVector
Storage for the rows in the table (each row is itself
a Vector
).
DefaultTableModel
public DefaultTableModel()
Creates an empty table with zero rows and zero columns.
DefaultTableModel
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 to null
).
numRows
- the number of rows.numColumns
- the number of columns.
DefaultTableModel
public DefaultTableModel(Object[] columnNames,
int numRows)
Creates a new table with the specified column names and row count.
columnNames
- the column names.numRows
- the number of rows.
DefaultTableModel
public DefaultTableModel(Object[][] data,
Object[] columnNames)
Creates a new table with the specified data values and column names.
data
- the data values.columnNames
- the column names.
DefaultTableModel
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.
columnNames
- the column names.numRows
- the number of rows.
DefaultTableModel
public DefaultTableModel(Vector<T> data,
Vector<T> columnNames)
Creates a new table with the specified data values and column names.
data
- the data values.columnNames
- the column names.
addColumn
public void addColumn(Object columnName)
Adds a column with the specified name to the table. All cell values
for the column are initially set to null
.
columnName
- the column name (null
permitted).
addColumn
public void addColumn(Object columnName,
Object[] columnData)
Adds a column with the specified name and data values to the table.
columnName
- the column name (null
permitted).columnData
- the column data.
addColumn
public void addColumn(Object columnName,
Vector<T> columnData)
Adds a column with the specified name and data values to the table.
columnName
- the column name (null
permitted).columnData
- the column data.
addRow
public void addRow(Object[] rowData)
Adds a new row containing the specified data to the table and sends a
TableModelEvent
to all registered listeners.
rowData
- the row data (null
permitted).
addRow
public void addRow(Vector<T> rowData)
Adds a new row containing the specified data to the table and sends a
TableModelEvent
to all registered listeners.
rowData
- the row data (null
permitted).
convertToVector
protected static Vector<T> convertToVector(Object[] data)
Converts the data array to a Vector
.
data
- the data array (null
permitted).
- A vector (or
null
if the data array
is null
).
convertToVector
protected static Vector<T> convertToVector(Object[][] data)
Converts the data array to a Vector
of rows.
data
- the data array (null
permitted).
- A vector (or
null
if the data array
is null
.
getValueAt
public Object getValueAt(int row,
int column)
Returns the value at the specified cell in the table.
- getValueAt in interface TableModel
row
- the row index.column
- the column index.
- The value (
Object
, possibly null
) at
the specified cell in the table.
insertRow
public void insertRow(int row,
Object[] rowData)
Inserts a new row into the table.
row
- the row index.rowData
- the row data.
insertRow
public void insertRow(int row,
Vector<T> rowData)
Inserts a new row into the table.
row
- the row index.rowData
- the row data.
moveRow
public void moveRow(int startIndex,
int endIndex,
int toIndex)
Moves the rows from startIndex
to endIndex
(inclusive) to the specified row.
startIndex
- the start row.endIndex
- the end row.toIndex
- the row to move to.
removeRow
public void removeRow(int row)
Removes a row from the table and sends a
TableModelEvent
to
all registered listeners.
setColumnCount
public void setColumnCount(int columnCount)
Sets the number of columns in the table. Existing rows are truncated
or padded with
null
values to match the new column count.
A
TableModelEvent
is sent to all registered listeners.
columnCount
- the column count.
setColumnIdentifiers
public void setColumnIdentifiers(Object[] columnIdentifiers)
Sets the column identifiers, updates the data rows (truncating
or padding each row with
null
values) to match the
number of columns, and sends a
TableModelEvent
to all
registered listeners.
columnIdentifiers
- the column identifiers.
setColumnIdentifiers
public void setColumnIdentifiers(Vector<T> columnIdentifiers)
Sets the column identifiers, updates the data rows (truncating
or padding each row with
null
values) to match the
number of columns, and sends a
TableModelEvent
to all
registered listeners.
columnIdentifiers
- the column identifiers.
setDataVector
public void setDataVector(Object[][] data,
Object[] columnNames)
Sets the data and column identifiers for the table.
data
- the data for the table.columnNames
- the column names.
setDataVector
public void setDataVector(Vector<T> data,
Vector<T> columnNames)
Sets the data and column identifiers for the table. The data vector
contains a Vector
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 adding
null
values) as required.
data
- the data for the table (a vector of row vectors).columnNames
- the column names.
setNumRows
public void setNumRows(int numRows)
numRows
- the number of rows.
setRowCount
public void setRowCount(int rowCount)
Sets the number of rows in the table. If rowCount
is less
than the current number of rows in the table, rows are discarded.
If rowCount
is greater than the current number of rows in
the table, new (empty) rows are added.
rowCount
- the row count.
DefaultTableModel.java --
Copyright (C) 2002, 2004, 2005, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.