aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JAVA move vertical scroll bar programatically by moving horizontal scroll bar. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JAVA move vertical scroll bar programatically by moving horizontal scroll bar." Watch "JAVA move vertical scroll bar programatically by moving horizontal scroll bar." New topic
Author

JAVA move vertical scroll bar programatically by moving horizontal scroll bar.

Prachi Sathe
Greenhorn

Joined: Oct 30, 2009
Posts: 6
JAVA move vertical scroll bar programatically by moving horizontal scroll bar. This is just a prototype to achive following.

There are 2 composites each with 1 table.
If i move the horizontal scroll in 1 it should move the horizontal scroll in other simultaniously.
The composites are not scroll composites.

Thanks you
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10266
    
    8

What have you tried so far and where are you stuck?


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Prachi Sathe
Greenhorn

Joined: Oct 30, 2009
Posts: 6
I was able to get the selection for the horizontal scroll bar for the first composite.
But I have no idea about how to increment the second composites scroll simultaniusly usning the value from the first scroll...

When tried to set the value on Composites using setLocation it moved the Composites instead of the data in the composite.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19672
    
  18

If the scrollbars have the same amount of scrolling and should always be in sync, you can set one's model to that of the other. Otherwise you'll need to add a listener to each scrollbar and update the other scrollbar if an event occurs. Be aware to not cause a StackOverflowError: if scrollbar 1 is moved, your code will move scrollbar 2, which triggers an event so scrollbar 1 is moved, which triggers an event so scrollbar 2 is moved, etc.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Prachi Sathe
Greenhorn

Joined: Oct 30, 2009
Posts: 6
@ Rob

The value is read from Swing table using
scrollValue = scrollPane.getHorizontalScrollBar().getValue()
and the tried setting the value in other Composite using the
table.getHorizontalBar().setSelection( scrollValue ); this is SWT Table.

This is not working for me

No clue how to proceed...
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19672
    
  18

Are you creating one user interface with both Swing and SWT controls?
Prachi Sathe
Greenhorn

Joined: Oct 30, 2009
Posts: 6
@ Rob
Yes
Swing component is already there. Th extension is SWT.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19672
    
  18

I don't think it's a good idea to mix two different GUI toolkits this way. Either use Swing or SWT, not both.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JAVA move vertical scroll bar programatically by moving horizontal scroll bar.