public class DefaultTableModel extends AbstractTableModel
A default implementation of the table model based on a two dimensional array.
Constructor and Description |
---|
DefaultTableModel(String[] columnNames,
Object[][] data)
Constructs a new table with a 2 dimensional array for row/column data
|
DefaultTableModel(String[] columnNames,
Object[][] data,
boolean editable)
Constructs a new table with a 2 dimensional array for row/column data
|
Modifier and Type | Method and Description |
---|---|
void |
addDataChangeListener(DataChangedListener d)
Adds a listener to the data changed event
|
void |
addRow(Object... row)
Adds the given row to the table data
|
int |
getColumnCount()
Returns the number of columns in the table
|
String |
getColumnName(int i)
Returns the name of the column at the given offset
|
int |
getRowCount()
Returns the number of rows in the table
|
Object |
getValueAt(int row,
int column)
Returns the value of the cell at the given location
|
void |
insertRow(int offset,
Object... row)
Inserts the given row to the table data at the given offset
|
boolean |
isCellEditable(int row,
int column)
Returns true if the cell at the given location is an editable cell
|
void |
removeDataChangeListener(DataChangedListener d)
Removes a listener to the data changed event
|
void |
removeRow(int offset)
Removes the given row offset from the table
|
void |
setValueAt(int row,
int column,
Object o)
Sets the value of the cell at the given location
|
getCellType, getMultipleChoiceOptions, getValidationConstraint, getValidator, setValidator
public DefaultTableModel(String[] columnNames, Object[][] data)
columnNames
- the names of the columnsdata
- the data within the tablepublic DefaultTableModel(String[] columnNames, Object[][] data, boolean editable)
columnNames
- the names of the columnsdata
- the data within the tableeditable
- indicates whether table cells are editable or not by defaultisCellEditable(int, int)
public int getRowCount()
public int getColumnCount()
public String getColumnName(int i)
i
- the offset for the column namepublic boolean isCellEditable(int row, int column)
row
- the cell rowcolumn
- the cell columnpublic Object getValueAt(int row, int column)
row
- the cell rowcolumn
- the cell columnpublic void setValueAt(int row, int column, Object o)
row
- the cell rowcolumn
- the cell columno
- the value of the cell at the given locationpublic void addDataChangeListener(DataChangedListener d)
d
- the new listenerpublic void removeDataChangeListener(DataChangedListener d)
d
- the listener to removepublic void addRow(Object... row)
row
- array or row items, notice that row.length should match the column count exactly!public void insertRow(int offset, Object... row)
offset
- position within the table that is 0 or larger yet smaller than the row countrow
- array or row items, notice that row.length should match the column count exactly!public void removeRow(int offset)
offset
- position within the table that is 0 or larger yet smaller than the row count