[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [SWT] Mouse wheel scrolling in Table

hi steve !

here a small example from me.

thnx in advance..

mac

import org.eclipse.swt.*;
import org.eclipse.swt.custom.*;
import org.eclipse.swt.dnd.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.program.*;
import org.eclipse.swt.widgets.*;
public class WheelExample {
Display display;
Shell shell;
Table table;
TableEditor tableEditor;
public static void main(String[] args) {
new WheelExample();
}
/**
* Constructor for WheelExample.
*/
public WheelExample() {
display = new Display();
shell = new Shell(display, SWT.SHELL_TRIM);
shell.setLayout(new FillLayout());
addMyTable();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
/**
* Method addMyTable.
*/
private void addMyTable() {
table = new Table(shell, SWT.H_SCROLL | SWT.SINGLE);
table.setLinesVisible(true);
table.setHeaderVisible(true);
TableColumn column1 = new TableColumn(table, SWT.NONE);
column1.setText("Button Column");
column1.setWidth(200);
TableColumn column2 = new TableColumn(table, SWT.NONE);
column2.setText("Text Column");
column2.setWidth(200);
for (int i = 0; i < 100; i++) {
TableItem item = new TableItem(table, SWT.NONE);
item.setText(1, "test " +i);
tableEditor= new TableEditor(table);
tableEditor.grabHorizontal = true;
tableEditor.grabVertical = true;
final Button b = new Button(table, SWT.TOGGLE | SWT.FLAT | SWT.CENTER);
b.setText("test button");
tableEditor.setEditor(b, item, 0);
}
}

}