I am accessing a database and trying to display them in JTable using count of 100.The resultset may well be very large (over 1,00,000 records).
The problem here is that I want to give user an illusion that He has got all the available data (for example,total number of record:5000), It means that scrollbar on the scrollpane should behave as if the JTable has got all the records(say 5000) but physically the table is holding just 100 records.
If user clicks the scrollbar down,using the index position I wish to display say 100 records to begin with, then as the user scrolls up and down the viewer further records are read from database and displayed.
Is there any solution for this.
Brian Cole
Author
Ranch Hand
Joined: Sep 20, 2005
Posts: 852
posted
0
I think JTable is already sort of designed to do what you want. If you write your table model's getValueAt() method to query the database for each cell, it will query just the visible cells, not all n*5000 of them. (Unless you're sorting the rows or something like that.)
Now of course you probably don't want to have to query the database each for every single call to getValueAt(), but I bet you can work out some kind of caching scheme.