• 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

Problem with JTable

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

I am facing some problem here from last two days, and not getting a way to solve it properly.

Problem Description:
I have a file which contains thousands of records, i want to show all those records in JTable, caching them all is a bad thing, since i could run in to OutOfMemory issue. so i thought of using pagination (did it successfully though) but the pagination with next and previous button is not a very user-friendly approach, so i thought of changing the vertical scroll bar behaviour to reflect pagination internally.
Meaning:
User will be given an illusion that Table contains all thousands of records but in reality only those records will be kept in memory which is visible to user. On slidding the Vertical scroll Bar knob up and down will eventually controll the fetching of records from file.

I have created a sample program for it, but i am not able to get it working properly, Any help on this , would be highly appreciated.

Files i have written is as follows:
1. OneLinerFileWriter.java (for testing purpose)
2. OneLinerFileReader.java (for testing purpose)
3. CustomTableModel.java
4. TableFrame.java

Here are the codes for the same:










Can someone please guide me through this?

regards
Akhil
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I ran your log.txt up to 10000 lines and this seems to work okay.
 
Akhil Jain
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks craig.
That seems to work fine, but again, i was achieving the same thing using previous and next button. which was working all fine.
Probalem:
However, i want to handle fetching of records by scrolling the knob down or just clicking on default up and down arrows of vertical scroll bar.
no radio buttons no previous next buttons anywhere with the table. just a message label at top of the table, where it keeps displaying, current record numbers shown to the user.
Can you please show me an example where you just scroll the knob down and it fetches next set of records (if currently visible rows are say, 1-15, then it should fetch records from 16-30 and show it to the user), need to control the unit increment, as well as block increments of the knob.

this way if user, slides the knob to the extreme bottom, he should be able to see actual records in that range from the file(say, file contains 10000 records, then on scrolling to the bottom, will fetch records 9985 - 10,000).
similar is applicable to moving up. so basically i want to do following things. which i am not able to do even with so many tries.

1. Calculate the initial JTable rows, which are visible to the user (row height is assumed to be same for all the rows.)

2. Displaying scroll bar knob size such that, giving a feel to user that, all records are present in table currently. but fetch and display only that much records which are visible to the user.

3. Identifying how down the user has actually moved the slider knob (block increment scenario) and fetching the records within that range, example, if initially, rows displayed are 1 to 20, then on scrolling the knob down say, 40 rows scrolled, then the current rows visible to the user should be 40 to 60.

I am completely, screwed up here.... any help form your side will be a great support craig.

regards,
Akhil
 
Akhil Jain
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can someone please....help me out here........
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I copied and ran the code you posted above. It seemed to scroll okay when holding a
scrollBar button but throws exceptions when I click on the scrollBar track. The number
sequences also seem to be off by the table row size. I don't think I could do what you are
asking for. The code I posted is the closest I can come to it.
 
Akhil Jain
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
NO problem craig...

Thanks for replies.

hey anyways...
here's my version of code with pagination......i was also not able to make it behave in a way i was asking above.

 
reply
    Bookmark Topic Watch Topic
  • New Topic