import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Slider;
import org.eclipse.swt.widgets.Spinner;
public class Main extends Composite {
private Spinner spinner = null;
private Slider slider = null;
public static void main(String[] args) {
Display display = Display.getDefault();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
shell.setSize(new Point(300, 200));
new Main(shell, SWT.NONE);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
public Main(Composite parent, int style) {
super(parent, style);
initialize();
}
private void initialize() {
this.setBounds(new Rectangle(0, 0, 300, 100));
FillLayout fillLayout = new FillLayout();
fillLayout.type = org.eclipse.swt.SWT.VERTICAL;
spinner = new Spinner(this, SWT.NONE);
spinner.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
slider.setSelection(spinner.getSelection());
}
});
slider = new Slider(this, SWT.NONE);
slider.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
spinner.setSelection(slider.getSelection());
}
});
this.setLayout(fillLayout);
}
}
2009年5月14日
Eclipse SWT Slider and Spinner
SWT Widgets
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言