Table Model Since the AbstractTableModel class has implemented most necessary methods, if you want to create a model that you can implement the most basic function, you only need to provide the following three methods: public int getRowcount (); public int getColumncount (); public object GetValueat (int Row, Int Column); of course, you can implement a getValueat method according to your own preferences, which will be reflected on the table's view, just simply returns data in the DATA array // return column Total public int getColumnCount () {return columnNames.length;} // returns the total number of rows available public int getRowCount () {return data.length;} // returns the column name public String getColumnName (int col) {return columnNames [col]; } // Returns the value of the specified location Public Object getValueat (int Row, int co) {Return Data [ROW] [col];} // Return Data Type Public Class getVolumnClass (INT C) {Return getValueat (0, c). Getclass ();
If you do not provide a column name, AbstractTableModel's getColumnName (int COL) will only be simply named: ABCD, etc. If you want to use your own name, it must be overloaded. / / Return to column name public string getColumnName (int co) {return columnname [col]}
Unit rendering and editing of the Edit JTABLE can only display a string, and there are still many display methods, which can implement Class getColumnClass (int columnIndex) method by overloading the getColumnClass method of AbstractTableModel, and returns the class getColumnClass (INT ColumnIndex) method Returns the class type. JTable will select the appropriate renderer based on the type returned. The following is the default renderer imageicon // image Boolean // check box