2011年1月16日 星期日

Swing JTable 的使用

使用 Swing JTable 的建議驟:

1.繼承 AbstractTableModel
2. 實作以下的方法:
  public int getRowCount();
  public int getColumnCount();
  public Object getValueAt(int row, int column);
  
   getValueAt() 的方法主要傳回儲存資料的集合中的值. 
3. 若要改變 table 的 header, 要覆寫以下方法:
  
 String getColumnName(int column)
 
4. 撰寫一方法, 設定或更新儲存資料的集合. 更新完後, 記得到執行 void fireTableDataChanged()
或者其它 void fireXXX 的方法, 將資料顯示出來. 

  

沒有留言: