我有一個包含來自 mysql 的資料的表。我想在選擇任何行時修改此資料,然后對資料庫進行修改
鏈接中的表格影像
uj5u.com熱心網友回復:
您可以使用TableCellListener來識別單元格資料何時發生實際更改,從而允許您使用 檢索單元格的當前值(新值)tcl.getNewValue(),以及使用 檢索舊值tcl.getOldValue()。此外,它還允許您獲取已修改單元格的row和索引。column
如上面來源中給出的示例:
Action action = new AbstractAction()
{
public void actionPerformed(ActionEvent e)
{
TableCellListener tcl = (TableCellListener)e.getSource();
System.out.println("Row : " tcl.getRow());
System.out.println("Column: " tcl.getColumn());
System.out.println("Old : " tcl.getOldValue());
System.out.println("New : " tcl.getNewValue());
}
};
TableCellListener tcl = new TableCellListener(table, action); // where table is the instance of your JTable
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/429882.html
