Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to scroll tables on both sides of splitpane in sync?

 
Sarone Thach
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi There,
I have a JScrollPane scrollpane1, I've added a JSplitPane. On each side of the split pane are a JTable. The JTables are in sync with eachother. row 1 of table on left, correspond to row1 data of table on right of splitpane.
However, I have a scrolling problem. When I need to scroll one table, i need to scroll the other by the same amount. Do i really need to put each of the table on a JScrollPane??
Or can I somehow manipulate the scrollpane1?
please could i get some help.
Thanks,
Sarone
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am still working on what needs to be done to actually move the other scrollpane, but I will work on it and let you know.
 
Sarone Thach
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok I have decided to put the JTable on a JScrollPane each.
I have used Gregg's code, and added a vertical adjustment listener.
if I can just set the vertical position of scrollbar1 to be the same as the vertical position of scrollbar2, the one we moved, it would work.
I'm searching in the api to see if I can do this.But can't find it.
If anyone can find it please let me know. Thanks.
 
Sarone Thach
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Problem solved:
Do not need an adjustment listener simply do this:

and another cool thing i tripped upon is this:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic