Reputation: 446
I'm working on a project in NetBeans
.
I have a Jtable
which i bound to my database and there is a form that I use to insert data.
I want the records in the table to be refreshed with each insert.
How can I do that?
Upvotes: 1
Views: 2991
Reputation: 9
Please try the following code:
if you want update the table on button click or on event of any component you have to put the code in the event
code
udetailsList.clear();
udetailsList.addAll(udetailsQuery.getResultList());
Upvotes: 0
Reputation: 446
I should simply select the table and go to the navigator window. Under "Other Components" there is the list that was created after the binding and contains the table records (you should know its name). Right click on the list > Properties > check "observable".
Upvotes: 1
Reputation: 324147
I want the records in the table to be refreshed with each insert.
Then your "insert" logic need to do two things:
addRow(...)
method of the DefaultTableModel
. You get the data from the form, create a Vector to contain the data for each column then you add the Vector to the model.Upvotes: 1