public class DefaultTableModel extends AbstractTableModel
TableModel implementation.| Constructor and Description |
|---|
DefaultTableModel()
Creates a new table model of 0x0 size.
|
DefaultTableModel(int columns,
int rows)
Creates a new table model with the specified dimensions.
|
DefaultTableModel(java.lang.Object[][] data,
java.lang.Object[] names)
Creates a new Table Model with the specified data and column names.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addRow(java.lang.Object[] rowData)
Adds a row containing the provided data to the end of the model.
|
void |
deleteRow(int row)
Deletes the specified row.
|
int |
getColumnCount()
Returns the number of columns in the table.
|
java.lang.String |
getColumnName(int column)
Returns column names using a "spreadsheet-style" convention, i.e.,
A, B, C...Y, Z, AA, AB, AC...
|
int |
getRowCount()
Returns the number of rows in the table.
|
java.lang.Object |
getValueAt(int column,
int row)
Returns the value found at the given coordinate within the table.
|
void |
insertRow(int row,
java.lang.Object[] rowData)
Inserts a row containing the provided data.
|
void |
setColumnCount(int newValue)
Sets the number of columns in the table.
|
void |
setColumnName(int column,
java.lang.String columnName)
Sets the name of the specified column.
|
void |
setRowCount(int newValue)
Sets the number of rows in the table.
|
void |
setValueAt(java.lang.Object newValue,
int column,
int row)
Sets the contents of the table cell at the specified coordinate.
|
addTableModelListener, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getEventListenerList, removeTableModelListenerpublic DefaultTableModel()
public DefaultTableModel(int columns,
int rows)
columns - the initial number of columnsrows - the initial number of rowspublic DefaultTableModel(java.lang.Object[][] data,
java.lang.Object[] names)
data - a two dimensional array containing the table data
(the first index of the array represents the column index,
and the second index represents the row index)names - the column namespublic void addRow(java.lang.Object[] rowData)
rowData - the row datapublic void deleteRow(int row)
row - the row to deletepublic int getColumnCount()
TableModelTableModel.getColumnCount()public java.lang.String getColumnName(int column)
AbstractTableModelgetColumnName in interface TableModelgetColumnName in class AbstractTableModelcolumn - the column index (0-based)TableModel.getColumnName(int)public int getRowCount()
TableModelTableModel.getRowCount()public java.lang.Object getValueAt(int column,
int row)
TableModelcolumn - the column index (0-based)row - the row index (0-based)TableModel.getValueAt(int, int)public void insertRow(int row,
java.lang.Object[] rowData)
row - the insertion indexrowData - the row datapublic void setColumnCount(int newValue)
newValue - the new column countpublic void setColumnName(int column,
java.lang.String columnName)
column - the column indexcolumnName - the new column namepublic void setRowCount(int newValue)
newValue - the new row countpublic void setValueAt(java.lang.Object newValue,
int column,
int row)
newValue - the new valuecolumn - the column indexrow - the row indexjava.lang.ArrayIndexOutOfBoundsException - if the column or row index
exceed the column or row count