*
The moose likes Swing / AWT / SWT and the fly likes Mirroring JScrollBars Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Mirroring JScrollBars" Watch "Mirroring JScrollBars" New topic
Author

Mirroring JScrollBars

Chris Stehno
Ranch Hand

Joined: Feb 26, 2001
Posts: 180
I have an application in which I need to have one vertical JScrollBar mirror another when moved... (e.g. if I scroll the first scroll bar, the second will scroll the same amount and direction.). I have tried to set the scroll bars value but am unable to specify a value for the bar to start at (and yes, it is between the min and max). My first step is to be able to specify the starting value of a scroll bar ... say, setting it to the middle of the bar... any suggestions?
Thanks in advance.


- Chris Stehno, SCPJ
Chris Stehno
Ranch Hand

Joined: Feb 26, 2001
Posts: 180
An addendum to my earlier post ... I can get this to work with simple scroll bars but for some reason I cannot do it with scroll bars extracted from a JScrollPane ... any ideas?
Chris Stehno
Ranch Hand

Joined: Feb 26, 2001
Posts: 180
I could really use some help with this one. Nothing I try works ... going through the JViewport and setting position, trying to set it on the JScrollBar ... nothing will allow the vertical scrollbar to be set. I have been able to set the horizontal, but that is only half my problem (and the solution to that part still does not do anything to the vertical).
Please help, this is getting really frustrating!
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Chris,
Is this what you are trying to do?

Enjoy,
Manfred.
Chris Stehno
Ranch Hand

Joined: Feb 26, 2001
Posts: 180
Close ... I want to do something similar with a JScrollPane (or the scrollbars in a JScrollPane). I was able figured out how to do it with normal scroll bars, but I cannot get it to work with scroll bars from a scroll pane.
What I need is the opposite of your example, basically ... I need the scroll bar to control the scrollbar in the scroll pane.
[This message has been edited by Chris Stehno (edited July 24, 2001).]
Chris Stehno
Ranch Hand

Joined: Feb 26, 2001
Posts: 180
Well I'll be damned! Something you showed me made it work ... I guess I just had the wrong approach. Thanks!
Josh Rehman
Ranch Hand

Joined: Jul 24, 2001
Posts: 63

I just wished to share that I like the style of your code, Manfred.
Originally posted by Manfred Leonhardt:
[B]Hi Chris,
Is this what you are trying to do?

Enjoy,
Manfred.[/B]


------------------
--
JavaJosh | | mailto://joshjava@yahoo.com | | <A HREF="http://joshbrain.tripod.com<br /> icq:" TARGET=_blank>http://joshbrain.tripod.com
icq: 457 9276 "Never neglect the fundamentals." Toshiro Kageyama
Good Java References´┐Ż: <A HREF="http://www.javaranch.com/index.html<br /> " TARGET=_blank>http://www.javaranch.com/index.html
 
 
subject: Mirroring JScrollBars
 
Similar Threads
JComboBox
DataTable Scroll bar Position Changing
JAVA move vertical scroll bar programatically by moving horizontal scroll bar.
How to increase the size of the <h:selectOneMenu> control.
Is there any way to bring the a Vertical Scroll Bars of the Scroll Pane at the Bottom by default???