This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
Hello all, I am a bit frustrated at this point. When doing a retrieve in my app, I am able to correctly populate my JTable with data. If I go in a second time and do another retrieve the data is correct, but it does not populate/refresh the JTable. I am using the AbstractTableModel and I have TableModelListeners on my Gui class. I can see the new data for a second or two in the JTable and then the table reverts back to the first requests' data. I also do a repaint() after each retrieve. Any suggestions are welcome !!!
How do you pass the data to the JTable, which method are you using? You shouldn't have to issue a repaint. You can create a new instance of your table model with the new data, and then call setModel. like this.
Mark, I am creating a new instance of my data model just as you have mentioned. The data in the model is correct, but the JTable refuses to refresh itself with the new data.
Joined: Feb 25, 2002
Pervez, I am not sure why your JTable is not refreshing with the new data. But you can check the items below. Obviously something is wrong. 1) When you create the table, put it in a JScrollPane 2) Create one instance of the table model and assign to the JTable during instantiation 3) When you get the new data, assign the new data to the table model. Below is the sample code:
Hey Sai what's fireTableDataChanged(); I didn't have that in my code and it displayed my data fine. Hmm. I wonder what I did? I just did setModel and then it would display without firing anything. Oh well, if it works for you with it, and doesn't without it, then you guys need it. Mark