aspose file tools
The moose likes Swing / AWT / SWT and the fly likes JTable W/Scrollbar Repainting Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "JTable W/Scrollbar Repainting Problem" Watch "JTable W/Scrollbar Repainting Problem" New topic
Author

JTable W/Scrollbar Repainting Problem

Robin K
Greenhorn

Joined: Jul 09, 2002
Posts: 1
Hi, Folks.
Here's my problem. I have a JTable with a horizontal scrollbar. I refresh the data using a Timer(). When the app first comes up, it's scrolled to the left. If the user is scrolled to the right when the data refreshes, the whole screen is repainted and it ends up scrolled to the left. How do I refresh the data but stay on the same part of the screen?
I tried using the fireTableDataChanged() method of the table model, but it didn't work.
Can anyone out there help me? Thanks in advance!
Chantal Ackermann
Ranch Hand

Joined: Sep 28, 2000
Posts: 508
maybe there is some better method to do it, but, well, try this:
get the value of the horizontal scrollbar, update the value (+ maybe you have to wait until the table gets refreshed and the horizontal scrollbar reset to left), and then set the scrollbar value to the former value (changed by the user).
The "better" possibility might be to either look for a method that sets a flag like "resetScrollbarOnUpdate()" though I haven't stumbled over a simimilar method until now. Or otherwise: Look through the source of javax.swing.JScrollPane, find the method where this behaviour is implemented and write a subclass that behaves as you like.
hope that helps
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: JTable W/Scrollbar Repainting Problem
 
Similar Threads
JTable
Problem repainting JTable
JTable
JTable
JTable