E
Edward H. Fabrega
AbstractTableModel is an abstract class. From the SRC code that comes with
JDK1.5.0-RC:
public abstract class AbstractTableModel implements TableModel, Serializable
{
//
// Instance Variables
//
/** List of listeners */
protected EventListenerList list
(snip)**************************************************
In the JTable class, one of the constructors goes like this:
public JTable(final Object[][] rowData, final Object[] columnNames) {
this(new AbstractTableModel() {
public String getColumnName(int column) { return
columnNames[column].toString(); }
public int getRowCount() { return rowData.length; }
public int getColumnCount() { return columnNames.length; }
public Object getValueAt(int row, int col) { return
rowData[row][col]; }
public boolean isCellEditable(int row, int column) { return
true; }
public void setValueAt(Object value, int row, int col) {
rowData[row][col] = value;
fireTableCellUpdated(row, col);
}
});
}
My question is concerning the creation of an instance of AbstractTableModel
in the JTable constructor with new. Isn't this illegal, and shouldn't it
generate a compile error because AbstractTableModel is an abstract class? I
was under the impression that attempting such a thing would cause a compile
error. Obviously I must be mistaken and am in need of some clarification.
JDK1.5.0-RC:
public abstract class AbstractTableModel implements TableModel, Serializable
{
//
// Instance Variables
//
/** List of listeners */
protected EventListenerList list
(snip)**************************************************
In the JTable class, one of the constructors goes like this:
public JTable(final Object[][] rowData, final Object[] columnNames) {
this(new AbstractTableModel() {
public String getColumnName(int column) { return
columnNames[column].toString(); }
public int getRowCount() { return rowData.length; }
public int getColumnCount() { return columnNames.length; }
public Object getValueAt(int row, int col) { return
rowData[row][col]; }
public boolean isCellEditable(int row, int column) { return
true; }
public void setValueAt(Object value, int row, int col) {
rowData[row][col] = value;
fireTableCellUpdated(row, col);
}
});
}
My question is concerning the creation of an instance of AbstractTableModel
in the JTable constructor with new. Isn't this illegal, and shouldn't it
generate a compile error because AbstractTableModel is an abstract class? I
was under the impression that attempting such a thing would cause a compile
error. Obviously I must be mistaken and am in need of some clarification.