JTable data not refreshing on UI when changing TableModel
Joined: Oct 14, 2004
I am facing a tough time here. I am using JTable and created my own custom pagination thing for it. I have a file which containf thousands of records and initially i want to show on 100 or so (anything which user specifies). for which i have created this UI Structure
A frame contains a JSplitPane, inside JSplitPane left component, i am setting a JPanel (viz. EventTablePanel), this panel contains 1 JScrollPane(say A) and 1 JPanel (say B). JScrollPane (A) vieweport has been set as JTable which have its backing TableModel. JPanel (B) has few buttons (like previous and next). Intially the table looks fine, when i read 100 records from the file. when user clicks on "NEXT button" inside JPanel (B), i set some indexes, based on which i repopulate the TableModel of JTable with new set of records. and after that i repaint the whole stuff like this.
Now, when i check the new scrollPane viewPort and its JTable's table model, i get the correct data (i.e, next 100 records with indexes 101 to 200), but its not getting repainted. i tried using invaildate, validate and what not. Can someone please help me out with this. What am i doing wrong here?
-------------------------------<br />you can't move ahead, unless you try for it.
Joined: Sep 20, 2005
Originally posted by Akhil Jain: when user clicks on "NEXT button" inside JPanel (B), i set some indexes, based on which i repopulate the TableModel of JTable with new set of records. and after that i repaint the whole stuff
You shouldn't have to repaint anything manually.
When the table model gets repopulated, make sure its fireTableDataChanged() method gets called and all should be well.