How to refresh Table
when im putting a data in JTextField. the data in JTextField is automatically insert in database. My problem is the table where the database record view is not update?
any Help!?
tnx in advance?
when im putting a data in JTextField. the data in JTextField is automatically insert in database. My problem is the table where the database record view is not update?
any Help!?
tnx in advance?
Do you use a JTable?
The table model has a method fireTableDataChanged()
(there are other methods starting with "fire..." in AbstractTableModel)
regards
BugBunny
Swing related questions should be posted in the Swing forum.
If you just want to update the value of a cell in a JTable, then use the JTable.setValueAt(...) method.
im using TableModel model = new AbstractTableModel.
the method i use is to remove the table then create other table..
> im using TableModel model = new AbstractTableModel.
No you aren't. You can't instaniate an Abstract class.
> the method i use is to remove the table then create other table..
Why? You said you update a text field. This implies only a single cell needs to be updated. So why would you create a whole new TableModel.
> how can i refresh AbstractTableModel?
Did you see my last comment? You are not using AbstractTableModel. You are using some class that extends AbstractTableModel. There is no method to refresh an AbstractTableModel.
You can update a TableModel one cell at a time using the setValueAt(...) method.
You can create a new TableModel and then update the table using the setModel(...) method.
Read the Swing tutorial on "How to Use Tables" for the basics:
http://java.sun.com/docs/books/tutorial/uiswing/components/table.html
> how can i refresh AbstractTableModel?
um,... did you read camikr's response above? You cannot instantiate much less refresh an abstract object.