2016-04-05 43 views

回答

1

新值可以從DefaultCellEditor得到。

button.addActionListener(new ActionListener() { 
     public void actionPerformed(ActionEvent e) { 

      if (table.getCellEditor() != null) { 
       DefaultCellEditor cellEditor = (DefaultCellEditor) table.getCellEditor(); 
       String value = ((JTextField) cellEditor.getComponent()).getText(); 
      } 

     } 
    }); 
+0

plz告訴我在哪裏添加此代碼 –

+0

您的按鈕的動作偵聽器。 – rdonuk

+0

檢查我更新的代碼。 – rdonuk

0

也許this解決方案將夠你:

table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); 

它不僅節省了當「保存」按鈕被點擊,而且在重點的變化等情況下,所有表數據。

相關問題