|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavax.swing.table.AbstractTableModel
javax.swing.table.DefaultTableModel
public class DefaultTableModel
A two dimensional data structure used to store Object
instances, usually for display in a JTable component.
| Field Summary | |
|---|---|
protected Vector |
columnIdentifiers
Storage for the column identifiers. |
protected Vector |
dataVector
Storage for the rows in the table (each row is itself a Vector). |
| Fields inherited from class javax.swing.table.AbstractTableModel |
|---|
listenerList |
| Constructor Summary | |
|---|---|
DefaultTableModel()
Creates an empty table with zero rows and zero columns. |
|
DefaultTableModel(int numRows,
int numColumns)
Creates a new table with the specified number of rows and columns. |
|
DefaultTableModel(Object[][] data,
Object[] columnNames)
Creates a new table with the specified data values and column names. |
|
DefaultTableModel(Object[] columnNames,
int numRows)
Creates a new table with the specified column names and row count. |
|
DefaultTableModel(Vector columnNames,
int numRows)
Creates a new table with the specified column names and number of rows. |
|
DefaultTableModel(Vector data,
Vector columnNames)
Creates a new table with the specified data values and column names. |
|
| Method Summary | |
|---|---|
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 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 rowData)
Adds a new row containing the specified data to the table and sends a TableModelEvent to all registered listeners. |
protected static Vector |
convertToVector(Object[] data)
Converts the data array to a Vector. |
protected static Vector |
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 |
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 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 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 data,
Vector 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. |
| Methods inherited from class javax.swing.table.AbstractTableModel |
|---|
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getListeners, getTableModelListeners, removeTableModelListener |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Vector dataVector
Vector).
protected Vector columnIdentifiers
| Constructor Detail |
|---|
public DefaultTableModel()
public DefaultTableModel(int numRows,
int numColumns)
null).
numRows - the number of rows.numColumns - the number of columns.
public DefaultTableModel(Vector columnNames,
int numRows)
columnNames - the column names.numRows - the number of rows.
public DefaultTableModel(Object[] columnNames,
int numRows)
columnNames - the column names.numRows - the number of rows.
public DefaultTableModel(Vector data,
Vector columnNames)
data - the data values.columnNames - the column names.
public DefaultTableModel(Object[][] data,
Object[] columnNames)
data - the data values.columnNames - the column names.| Method Detail |
|---|
public Vector getDataVector()
public void setDataVector(Vector data,
Vector columnNames)
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.
NullPointerException - if either argument is null.
public void setDataVector(Object[][] data,
Object[] columnNames)
data - the data for the table.columnNames - the column names.
NullPointerException - if either argument is null.public void newDataAvailable(TableModelEvent event)
event to all registered listeners.
This method is equivalent to
AbstractTableModel.fireTableChanged(TableModelEvent).
event - the event.public void newRowsAdded(TableModelEvent event)
event to all registered listeners.
This method is equivalent to
AbstractTableModel.fireTableChanged(TableModelEvent).
event - the event.public void rowsRemoved(TableModelEvent event)
event to all registered listeners.
This method is equivalent to
AbstractTableModel.fireTableChanged(TableModelEvent).
event - the event.public void setColumnIdentifiers(Vector columnIdentifiers)
null values) to match the
number of columns, and sends a TableModelEvent to all
registered listeners.
columnIdentifiers - the column identifiers.public void setColumnIdentifiers(Object[] columnIdentifiers)
null values) to match the
number of columns, and sends a TableModelEvent to all
registered listeners.
columnIdentifiers - the column identifiers.public void setNumRows(int numRows)
setRowCount(int) instead.
numRows - the number of rows.public void setRowCount(int rowCount)
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.public void setColumnCount(int columnCount)
null values to match the new column count.
A TableModelEvent is sent to all registered listeners.
columnCount - the column count.public void addColumn(Object columnName)
null.
columnName - the column name (null permitted).
public void addColumn(Object columnName,
Vector columnData)
columnName - the column name (null permitted).columnData - the column data.
public void addColumn(Object columnName,
Object[] columnData)
columnName - the column name (null permitted).columnData - the column data.public void addRow(Vector rowData)
TableModelEvent to all registered listeners.
rowData - the row data (null permitted).public void addRow(Object[] rowData)
TableModelEvent to all registered listeners.
rowData - the row data (null permitted).
public void insertRow(int row,
Vector rowData)
row - the row index.rowData - the row data.
public void insertRow(int row,
Object[] rowData)
row - the row index.rowData - the row data.
public void moveRow(int startIndex,
int endIndex,
int toIndex)
startIndex to endIndex
(inclusive) to the specified row.
startIndex - the start row.endIndex - the end row.toIndex - the row to move to.public void removeRow(int row)
TableModelEvent to
all registered listeners.
row - the row index.public int getRowCount()
getRowCount in interface TableModelpublic int getColumnCount()
getColumnCount in interface TableModelpublic String getColumnName(int column)
AbstractTableModel.getColumnName(int).
getColumnName in interface TableModelgetColumnName in class AbstractTableModelcolumn - the column index.
public boolean isCellEditable(int row,
int column)
true if the specified cell can be modified, and
false otherwise. For this implementation, the method
always returns true.
isCellEditable in interface TableModelisCellEditable in class AbstractTableModelrow - the row index.column - the column index.
true in all cases.
public Object getValueAt(int row,
int column)
getValueAt in interface TableModelrow - the row index.column - the column index.
Object, possibly null) at
the specified cell in the table.
public void setValueAt(Object value,
int row,
int column)
TableModelEvent to all registered listeners.
setValueAt in interface TableModelsetValueAt in class AbstractTableModelvalue - the value (Object, null permitted).row - the row index.column - the column index.protected static Vector convertToVector(Object[] data)
Vector.
data - the data array (null permitted).
null if the data array
is null).protected static Vector convertToVector(Object[][] data)
Vector of rows.
data - the data array (null permitted).
null if the data array
is null.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||