TableModel interface specifies the methods the
JTable will use to interrogate a tabular data model.
The JTable can be set up to display any data
model which implements the
TableModel interface with a couple of lines of code:
TableModel myData = new MyTableModel();
JTable table = new JTable(myData);
For further documentation, see Creating a Table Model in The Java Tutorial.
JTable
| Modifier and Type | Method and Description |
|---|---|
| public void | addTableModelListener(TableModelListener
the TableModelListener l)Adds a listener to the list that is notified each time a change to the data model occurs. |
| public Class | Returns: the common ancestor class of the object values in the model.the index of the column columnIndex)Returns the most specific superclass for all the cell values in the column. |
| public int | Returns: the number of columns in the modelReturns the number of columns in the model. |
| public String | Returns: the name of the columnthe index of the column columnIndex)Returns the name of the column at |
| public int | |
| public Object | Returns: the value Object at the specified cellthe row whose value is to be queried rowIndex, int the column whose value is to be queried columnIndex)Returns the value for the cell at |
| public boolean | Returns: true if the cell is editablethe row whose value to be queried rowIndex, int the column whose value to be queried columnIndex)Returns true if the cell at |
| public void | removeTableModelListener(TableModelListener
the TableModelListener l)Removes a listener from the list that is notified each time a change to the data model occurs. |
| public void | setValueAt(Object
the new value aValue, int the row whose value is to be changed rowIndex, int the column whose value is to be changed columnIndex)Sets the value in the cell at |
| addTableModelListener | back to summary |
|---|---|
| public void addTableModelListener(TableModelListener l) Adds a listener to the list that is notified each time a change to the data model occurs.
| |
| getColumnClass | back to summary |
|---|---|
| public Class Returns the most specific superclass for all the cell values
in the column. This is used by the
| |
| getColumnCount | back to summary |
|---|---|
| public int getColumnCount() Returns the number of columns in the model. A
| |
| getColumnName | back to summary |
|---|---|
| public String getColumnName(int columnIndex) Returns the name of the column at Note this name does not need to be unique; two columns in a table can have the same name.
| |
| getRowCount | back to summary |
|---|---|
| public int getRowCount() Returns the number of rows in the model. A
| |
| getValueAt | back to summary |
|---|---|
| public Object getValueAt(int rowIndex, int columnIndex) Returns the value for the cell at
| |
| isCellEditable | back to summary |
|---|---|
| public boolean isCellEditable(int rowIndex, int columnIndex) Returns true if the cell at
| |
| removeTableModelListener | back to summary |
|---|---|
| public void removeTableModelListener(TableModelListener l) Removes a listener from the list that is notified each time a change to the data model occurs.
| |
| setValueAt | back to summary |
|---|---|
| public void setValueAt(Object aValue, int rowIndex, int columnIndex) Sets the value in the cell at
| |