Originally posted by Arun Sanker:
paging model implemented with the table when handling large amounts of data.
The table shows only 100 entries at a time in the table.The next or previous 100 entries are got by clicking the corner buttons("Down" or "Up" buttons) in the scroll pane.
I want the table to behave in a different way ,without this corner buttons.
[1]The scrollbars should look in a way that the Table is filled with all the data's.Can we mimic the Tablemodel to do something like this?
When someone
asked this a couple years ago I answered that JTable is already sort of
designed to do this. By that I meant that your table can have a million rows, but your table model will only be asked about the rows that it needs to display on screen, not all million rows.
I don't think people understood what I was getting at, though, so I'll put my money where my mouth is:
If you run this, whip the scroll bar quickly down to the 800,000th row or so, and watch the console, you'll see that it doesn't have to load all 800,000 intervening rows of data. It only has to load a couple thousand rows of data to do that, depending on how fast you drag the scroll thumb.
If you replace
new JScrollPane(tab) with
LazyViewport.createLazyScrollPaneFor(tab) in main it doesn't even have to load that many, but this post is too long already. I'll save the implementation of LazyViewport for another post.