File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes JTable Paging Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable Paging" Watch "JTable Paging" New topic
Author

JTable Paging

Arun Sanker
Ranch Hand

Joined: Mar 21, 2007
Posts: 44
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
Krishnamoorthy Vuyala Muralidharan
Ranch Hand

Joined: Sep 13, 2005
Posts: 52
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
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19543
    
  16

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Brian Cole
Author
Ranch Hand

Joined: Sep 20, 2005
Posts: 862
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.


bitguru blog
Brian Cole
Author
Ranch Hand

Joined: Sep 20, 2005
Posts: 862
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

Joined: Mar 21, 2007
Posts: 44
Thanks Krishnamoorthy,Rob,Brian.....

Thanks a lot....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTable Paging
 
Similar Threads
Getting started with AWT and Swing
Problem with row focus and scroll
Hardcore GUI Design and downloadable components
Icon needed in JTableHeader for Sorting
Displaying information in other language[tamil]