• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

JTable problem.

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have one problem regarding the JTable.
I have to implement next , previous option in jtable.
My problem is I have say 1000 records but i dont want to display entire records in a table at a time.
I want 10 records first time then when user press next button then next 10 records should come in the table.
Could any body suggest me how to do that.... or any sample example.

Best Regards -
Vikas Kumar Sahu.
 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you considered writing your own TableModel?
 
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had a similar problem. The way I dealt with it was to create a "controller" that was passed a JTable and a model containing the records and had a set "page" size which was the number of records displayed. The controller provided next() and previous() methods. When invoked the controller would remove all the existing rows, if any, and then add the next (or previous) page size records as rows. You could also eliminate the adding/removing and just update the cells.

You could certainly roll your own TableModel to do it too but I have concerns about it. I'm just not sure a TableModel should be taking on the responsibility of deciding which rows are visible at a given time. But that's just my initial reaction so take it for what it's worth.
[ December 29, 2005: Message edited by: Ken Blair ]
 
You don't know me, but I've been looking all over the world for. Thanks to the help from this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic