Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Prachi Sathe
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11027
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What have you tried so far and where are you stuck?
 
Prachi Sathe
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20531
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Prachi Sathe
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@ 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
Pie
Posts: 20531
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you creating one user interface with both Swing and SWT controls?
 
Prachi Sathe
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@ Rob
Yes
Swing component is already there. Th extension is SWT.
 
Rob Spoor
Sheriff
Pie
Posts: 20531
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think it's a good idea to mix two different GUI toolkits this way. Either use Swing or SWT, not both.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic