-
JTable problem
Hi there,
In my program I use a JTable thats in a Jpanel to list all my users on it.
There is also a posibility to delete one of those users.
But then the problem starts the JTable stays like it is and I want to refresh it. I know there is a JLissener or something but I dont know how that works.
Is there also another posibility to refresh the panel or Jtable to update my data for the Jtable.
also the option revalidate with a panel seems to doesnt work :s
Can someone please help me
-
The JTable listens to the TableModel so it can know when to update itself. Use a DefaultTableModel and make data additons/deletions to it. Depending on the methods you use you may have to use a method in the AbstractTableModel class to announce the change(s). The table will hear about the changes.
Put the JTable in a JScrollPane and eliminate the JPanel. Add the scrollPane to the container that you had added the panel to earlier. JTable implements the Scrollable interface so it knows how to communicate with the parent scrollPane.