jtable中的内容改变了会触发什么事件?
还有怎么把table中的改变存入database?是不是通过改变resultSet中的内容?

解决方案 »

  1.   

    给你一段英语的,里面说得很清楚了.
        If you have a class such as SimpleTableDemo that isn't a table or table model, but needs to react to changes in a table model, then you need to do something special to find out when the user edits the table's data. Specifically, you need to register a TableModelListener on the table model. Adding the bold code in the following snippet makes SimpleTableDemo react to table data changes. import javax.swing.event.*;
    import javax.swing.table.TableModel;public class SimpleTableDemo ... implements TableModelListener {
        ...
        public SimpleTableDemo() {
            ...
            table.getModel().addTableModelListener(this);
            ...
        }    public void tableChanged(TableModelEvent e) {
            int row = e.getFirstRow();
            int column = e.getColumn();
            TableModel model = (TableModel)e.getSource();
            String columnName = model.getColumnName(column);
            Object data = model.getValueAt(row, column);        ...// Do something with the data...
        }
        ...
    }