I am using JXTable to display a list of records.
When I click "Refresh" button, I want the JXTable to be refreshed to display the newly inserted records.
And also when I click "Add new Row" button, a new row must be added to JXTable.
How can I do these? I am unable to find any useful reference or samples. Please guide me.
It works the same as with a regular JTable
, which is all explained in the table tutorial. But to answer your questions:
TableModel
. The moment you update your TableModel
you should fire the appropriate events so that the JTable
is aware of the changes made to the model. At that moment, the JTable
will refresh itself automatically. If your TableModel
extends from DefaultTableModel
there are already methods available which take care of the events (like e.g. insertRow
)TableModel
+ firing the appropriate events. If you use a DefaultTableModel
, you can use the available API of the DefaultTableModel