• Post Reply Bookmark Topic Watch Topic
  • New Topic

sinc scrollbars

 
Nikos Stavros
Ranch Hand
Posts: 243
Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
say I have 3 JText Areas in 2 scrollpanes with the same Dimensions.
How can I sinc the scrollbars so the rows are always alinged with each other
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The scrollbars need to listen to each other, so that they adjust themselves when the other changes.

I have some utility code at work which does exactly this. If you can wait until tomorrow, I can post it.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
get the scrollbars from their scrollpanes
JScrollBar sb1 = scrollpane1.getVerticalScrollBar();
JScrollBar sb2 = scrollpane2.getVerticalScrollBar();

synchronize them by setting their models the same
sb2.setModel(sb1.getModel());
 
Nikos Stavros
Ranch Hand
Posts: 243
Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok thanks for your code at work Ilja, and thanks for the sample code Michael
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!