• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JTable Paging

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,

I intend to use the following paging model implemented with the table when handling large amounts of data.

http://www.java2s.com/Code/Java/Swing-JFC/AquickapplicationthatdemonstratesthePagingModel.htm

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?

[2]The table should be filled with the next 100 or previous 100 entries while scrolling up & down the table, either using the scroll bar,the arrow buttons in the scroll bar or when he selects a row in the table and uses the up,down arrow keys of the keyboard.

For the end user, the behaviour of the Table is as if the whole list of data is loaded into the Table.

Is this possible or what could be done to achieve something close to this...What shoule be changed in the PagingModel.Java file

Thanks
P
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

Please take a look at the below blog which addresses your issue:

http://looksgoodworkswell.blogspot.com/2005/06/death-to-paging-rico-livegrid-released.html

Hope this helps.

Kind regards
Kris
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The table uses a TableModel for all of this:
- getRowCount() for the number of rows, so also for the scrollbars
- getValueAt(int row, int column) for the data of a specific cell

Now the default table model implementations usually store all data all the time, but nothing prevents you from writing your own implementation instead that only retrieves data as necessary.
Best approach is to extend AbstractTableModel so you won't have to code the events that need to be raised. All you need to do is call the right fire* method.
 
Author
Posts: 986
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Brian Cole
Author
Posts: 986
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Brian Cole:
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.



I forgot that I owed a post on LazyViewport. Sorry about that.

I've explained it at http://bitguru.wordpress.com/2008/01/07/lazyviewport/
 
Arun Sanker
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Krishnamoorthy,Rob,Brian.....

Thanks a lot....
 
reply
    Bookmark Topic Watch Topic
  • New Topic