使用 Swing JTable 的建議驟:
1.繼承 AbstractTableModel
- 實作以下的方法:
public int getRowCount(); public int getColumnCount(); public Object getValueAt(int row, int column);
getValueAt() 的方法主要傳回儲存資料的集合中的值.
3. 若要改變 table 的 header, 要覆寫以下方法:
String
<b>getColumnName</b>(int column)
4. 撰寫一方法, 設定或更新儲存資料的集合. 更新完後, 記得到執行
<b><a href="http://download.oracle.com/javase/1.4.2/docs/api/javax/swing/table/AbstractTableModel.html#fireTableDataChanged%28%29">void fireTableDataChanged</a></b>()
或者其它 void fireXXX 的方法, 將資料顯示出來.
沒有留言:
張貼留言