|
|
Re: Scroll two tables at the same time [message #444371 is a reply to message #444367] |
Tue, 12 October 2004 13:34 |
Veronika Irvine Messages: 1272 Registered: July 2009 |
Senior Member |
|
|
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
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.03176 seconds