• 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
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

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

 
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
 
Ranch Hand
Posts: 15304
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:
 
You can thank my dental hygienist for my untimely aliveness. So tiny:
ScroogeXHTML - small and flexible RTF to HTML converter library
https://coderanch.com/t/710903/ScroogeXHTML-RTF-HTML-XHTML-converter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!