• 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

erratic scrolling behavior with JTable with variable height rows

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I downloaded the source from this book: http://java.sun.com/developer/Books/gui/swing2/
for the variable row height JTable found at the end of Chapter 18. I modified it to handle 351 rows of varying size data. It is appended at the end of this message as a single file named ExpenseReport.java. I also added a refresh button whose actionPerformed() refreshes the JTable by a fireTableChanged. This button is the third button over

Straightforward stuff, right? Well, compile this file and run it. Scroll to (say) 75% with the scrollbar. Click the refresh button. The scrollbar jumps to the top and the user loses his place. Is there anyway to fix this example, so that I can apply it to my problem? The solution has eluded all of us.

Thanks for any help.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try editing your post to add code tags around the code, so we can read/copy it in the correct format
 
Sheriff
Posts: 22784
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
It seems as though your table does not get notified properly about the row height initially. I tried it full screen on a 2560x1600 resolution, and refreshing decreased the sroll bar button with around 10 pixels. If I remove the call to table.setRowHeight that no longer occurs.
 
reply
    Bookmark Topic Watch Topic
  • New Topic