Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » SWT Table - Synchronized Scrolling
SWT Table - Synchronized Scrolling [message #440506] Tue, 03 August 2004 16:24 Go to next message
Wayne Williams is currently offline Wayne WilliamsFriend
Messages: 4
Registered: July 2009
Junior Member
I've got two tables, both with horizontal and vertical scroll bars. When
the scroll bar is moved in one table, I want the other table to scroll the
same amount.

Anyone know how to acomplish this? I've tried a few different approaches
but have had no luck.

Regards,
---Wayne.
Re: SWT Table - Synchronized Scrolling [message #440585 is a reply to message #440506] Wed, 04 August 2004 11:48 Go to previous messageGo to next message
Rob Warner is currently offline Rob WarnerFriend
Messages: 9
Registered: July 2009
Junior Member
Keeping tables vertically in sync can be accomplished fairly simply. Given
tables "left" and "right," you can use code like this:

// Sync the right to the left
((Scrollable) left).getVerticalBar().addSelectionListener(new
SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
right.setTopIndex(left.getTopIndex());
}
});

// Sync the left to the right
((Scrollable) right).getVerticalBar().addSelectionListener(new
SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
left.setTopIndex(right.getTopIndex());
}
});

Keeping in sync horizontally is a different matter--either it can't
currently be done, or someone smarter than I will have to tell you. You
can (kind of) keep the scrollbars in sync like this (I left out the left
to right sync code):

// Sync the right to the left
((Scrollable) left).getHorizontalBar().addSelectionListener(new
SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
ScrollBar rsb = ((Scrollable) right).getHorizontalBar();
rsb.setSelection(((ScrollBar) event.widget).getSelection());
}
});

But that doesn't actually scroll the table, so it's essentially useless.

HTH.

Wayne Williams wrote:

> I've got two tables, both with horizontal and vertical scroll bars. When
> the scroll bar is moved in one table, I want the other table to scroll the
> same amount.

> Anyone know how to acomplish this? I've tried a few different approaches
> but have had no luck.

> Regards,
> ---Wayne.
Re: SWT Table - Synchronized Scrolling [message #440881 is a reply to message #440585] Mon, 09 August 2004 05:53 Go to previous message
Joe is currently offline JoeFriend
Messages: 12
Registered: July 2009
Junior Member
Keeping in sync horizontally:
((Scrollable) left).getHorizontalBar().addSelectionListener(new
SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
((Scrollable) right).getHorizontalBar().setSelection(
((Scrollable) left).getHorizontalBar().getSelection());
}
});
((Scrollable) right).getHorizontalBar().addSelectionListener(new
SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
((Scrollable) left).getHorizontalBar().setSelection(
((Scrollable) right).getHorizontalBar().getSelection());
}
});

Rob Warner wrote:

> Keeping tables vertically in sync can be accomplished fairly simply. Given
> tables "left" and "right," you can use code like this:

> // Sync the right to the left
> ((Scrollable) left).getVerticalBar().addSelectionListener(new
> SelectionAdapter() {
> public void widgetSelected(SelectionEvent event) {
> right.setTopIndex(left.getTopIndex());
> }
> });

> // Sync the left to the right
> ((Scrollable) right).getVerticalBar().addSelectionListener(new
> SelectionAdapter() {
> public void widgetSelected(SelectionEvent event) {
> left.setTopIndex(right.getTopIndex());
> }
> });

> Keeping in sync horizontally is a different matter--either it can't
> currently be done, or someone smarter than I will have to tell you. You
> can (kind of) keep the scrollbars in sync like this (I left out the left
> to right sync code):

> // Sync the right to the left
> ((Scrollable) left).getHorizontalBar().addSelectionListener(new
> SelectionAdapter() {
> public void widgetSelected(SelectionEvent event) {
> ScrollBar rsb = ((Scrollable) right).getHorizontalBar();
> rsb.setSelection(((ScrollBar) event.widget).getSelection());
> }
> });

> But that doesn't actually scroll the table, so it's essentially useless.

> HTH.

> Wayne Williams wrote:

> > I've got two tables, both with horizontal and vertical scroll bars. When
> > the scroll bar is moved in one table, I want the other table to scroll the
> > same amount.

> > Anyone know how to acomplish this? I've tried a few different approaches
> > but have had no luck.

> > Regards,
> > ---Wayne.
Previous Topic:How to hide Scrollbars in StyledText if not needed?
Next Topic:JFace TableViewer not updating edited cell
Goto Forum:
  


Current Time: Thu Apr 25 18:08:20 GMT 2024

Powered by FUDForum. Page generated in 0.02945 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top