I am creating a JTable using its JTable(vector,vector) constructor. Does this create a DefaultTableModel?

Davanum Srinivas

No, JTable(Vector,Vector) does not create DefaultTableModel. you can find the sources in the src.jar in your JDK1.2.2 or JDK1.3 installation. Here's the snippet from JTable.java. Of course, There is no guarantee that this is true for the next version of JDK.

    public JTable(final Vector rowData, final Vector columnNames) {
        this(new AbstractTableModel() {
            public String getColumnName(int column) { return columnNames.elementAt(column).toString(); }
            public int getRowCount() { return rowData.size(); }
            public int getColumnCount() { return columnNames.size(); }
            public Object getValueAt(int row, int column) {
                return ((Vector)rowData.elementAt(row)).elementAt(column);
            public boolean isCellEditable(int row, int column) { return true; }
            public void setValueAt(Object value, int row, int column) {
                ((Vector)rowData.elementAt(row)).setElementAt(value, column);
                fireTableCellUpdated(row, column);
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact