• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to let a scrollBar of one pane to control the other pane?  RSS feed

 
Steve Clark
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a VERTICAL splitpane, it include 2 scrollpanes and 1 JPanel.

I want to a scrollBar of one scrollpane to control the other 2 panes at the same time.

if moving the scrollBar , then the whole splitpane move together.
 
Michael Dunn
Ranch Hand
Posts: 4632
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
 
Rob Spoor
Sheriff
Posts: 21048
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have two JScrollPanes, simply let them share a model:

If not, you will have to use an AdjustmentListener.
 
Brian Cole
Author
Ranch Hand
Posts: 947
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Steve Clark wrote:I have a VERTICAL splitpane, it include 2 scrollpanes and 1 JPanel.

I want to a scrollBar of one scrollpane to control the other 2 panes at the same time.

if moving the scrollBar , then the whole splitpane move together.


I'm confused. You have two scroll panes and another panel that isn't in a scroll pane, but you want
them all to scroll together??

I won't say it's impossible, but it would be a lot easier if you put the panel in a scroll pane too, so
they can share bounded range models. You can even hide the scroll bar of the scroll pane holding
the panel, so it doesn't look like its in a scroll pane. See http://www.coderanch.com/t/345900/ for
an example of locked scrolling with a hidden scroll bar.

Alternatively, you could place the entire contents of your split pane in a single scroll pane. Then of
course they would scroll together.

 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!