• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Refreshing Display of JTable

 
David Reck
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using a JTable with a class I wrote exteding AbstractTableModel for the data model. When I perform a search on the gui I update the data in the model, but to get the new search results to be displayed I have to click on a column header on the table. Then the results are displayed correctly. I have tried to call repaint() and updateGUI() on the table to refresh the view after the search but I get null pointer exception on both of them. What is the proper way to refresh the display of data from the updated values in the model on the JTable?
Thanks,
Dave
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remember to call fireTableDataChanged() in your AbstractTableModel subclass when you update the data it holds...
Hope this helps!!!
Benjam´┐Żn
 
Ravikiran Choppalli
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a update() function in your customtablemodel class, pass the data that needs to be updated and call fireTableDataChanged(). This WORKS.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic