Hi Friends, i have connected my database table to jtable, but i dont no how to refresh that table after adding or removing some data from it.
Thanks
Hi Friends, i have connected my database table to jtable, but i dont no how to refresh that table after adding or removing some data from it.
Thanks
Listening for Data Changes
A table model can have a set of listeners that are notified whenever the table data changes. Listeners are instances of TableModelListener. In the following example code, SimpleTableDemo is extended to include such a listener.
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...
}
...
}
Bookmarks