Scroll two tables at the same time [message #444367] |
Tue, 12 October 2004 08:57  |
Eclipse User |
|
|
|
Hi
I want to be able to scroll two tables at the same time - the tables has the
same number of columns.
So if I scroll the first table, the second table scrolls to the same
position and vice versa.
I was looking for some sort of scroll listener, but couldn't find one.
Any ideas ?
/Henrik
|
|
|
|
Re: Scroll two tables at the same time [message #444371 is a reply to message #444367] |
Tue, 12 October 2004 09:34   |
Eclipse User |
|
|
|
One way to scroll two tables vertically at the same time is to use a
ScrolledComposite and have one scrollbar for the two tables.
The solution depends on how you want your GUI to be laid out.
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
ScrolledComposite sc = new ScrolledComposite(shell, SWT.V_SCROLL);
Composite parent = new Composite(sc, SWT.NONE);
parent.setLayout(new GridLayout(2, false));
Table table1 = new Table(parent, SWT.BORDER);
TableColumn column1a = new TableColumn(table1, SWT.NONE);
TableColumn column2a = new TableColumn(table1, SWT.NONE);
for (int i = 0; i < 100; i++) {
TableItem item = new TableItem(table1, SWT.NONE);
item.setText(new String[] { "left item " + i, "column 1 " +
i });
}
column1a.pack();
column2a.pack();
Table table2 = new Table(parent, SWT.BORDER);
TableColumn column1b = new TableColumn(table2, SWT.NONE);
TableColumn column2b = new TableColumn(table2, SWT.NONE);
for (int i = 0; i < 100; i++) {
TableItem item = new TableItem(table2, SWT.NONE);
item.setText(new String[] { "right item " + i, "column 1 " +
i });
}
column1b.pack();
column2b.pack();
Point size = parent.computeSize(SWT.DEFAULT, SWT.DEFAULT);
parent.pack();
sc.setExpandVertical(true);
sc.setContent(parent);
sc.setMinHeight(size.y);
size = shell.computeSize(SWT.DEFAULT, 200);
shell.setSize(size);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
"Henrik Skovgaard" <hsk@reklamedata.dk> wrote in message
news:ckgk1d$44k$1@eclipse.org...
> Hi
>
> I want to be able to scroll two tables at the same time - the tables has
> the same number of columns.
> So if I scroll the first table, the second table scrolls to the same
> position and vice versa.
> I was looking for some sort of scroll listener, but couldn't find one.
>
> Any ideas ?
>
> /Henrik
>
|
|
|
Re: Scroll two tables at the same time [message #444374 is a reply to message #444368] |
Tue, 12 October 2004 10:07  |
Eclipse User |
|
|
|
"Lorenz Maierhofer" <lorenz.m@gmx.at> wrote in message
news:ckgkq6$5qp$1@eclipse.org...
> Hi,
>
>> I want to be able to scroll two tables at the same time - the tables has
>> the same number of columns.
>
> I did exactly that, but was never really happy with the results.
Thanks for your replies. I'll try to run the example I got to see how it
looks. Thing is, that I DO have a horizontal scroll in one of the tables,
and not in the other.
Cheers,
/Henrik
|
|
|
Powered by
FUDForum. Page generated in 0.03439 seconds