Java by API/org.eclipse.swt.widgets/Listener
Версия от 17:43, 31 мая 2010; (обсуждение)
implements Listener
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
public class MainClass {
public static void main(String[] a) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
// Create a table and column
final Table table = new Table(shell, SWT.VIRTUAL);
table.setLinesVisible(true);
table.setHeaderVisible(true);
TableColumn tc = new TableColumn(table, SWT.NONE);
tc.setText("Virtual Value");
tc.setWidth(400);
// Tell the table how many items it has
table.setItemCount(100);
// Provide the callback handler--this handler
// is invoked when the table needs new rows
table.addListener(SWT.SetData, new Listener() {
public void handleEvent(Event event) {
TableItem item = (TableItem) event.item;
item.setText("data");
}
});
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
}