I want to update the value of the cell I've selected in JTable
, which should reflect the database ( HSQL
) as button's listener is called upon.
JButton button = new JButton("VIEW AND EDIT");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int row = table.getSelectedRow();
int column = table.getSelectedColumn();
//(**********************)
System.out.println(row + " : " + column);
table.requestFocus();
}
});
What piece of code should I replace with the *
s?
PLEASE provide me with, either a sample code, or process to do the same.
My table has 4 columns with one PK
.
If you want to update the table so it matches the current state of your DB, you should
TableModel
on the worker thread, and set it on the existing table on the Event Dispatch Thread OR If you want to edit the values in the table, and push that state to your DB
TableModel
receives the update (in the setValueAt
method), push that state to the database on a worker thread Relevant links:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.