xyg_1980
发贴: 5
积分: 0
|
于 2006-11-21 22:08
代码如下 : import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.ToolBar; import org.eclipse.swt.widgets.ToolItem; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.custom.ViewForm;
public class helloworld {
/** * Launch the application * @param args */ public static void main(String[] args) { final Display display = Display.getDefault(); final Shell shell = new Shell(); shell.setSize(500, 375); shell.setText("SWT Application"); //
shell.setLayout(new FillLayout()); ViewForm viewForm=new ViewForm(shell,SWT.NONE); viewForm.setLayout(new FillLayout()); ToolBar toolBar = new ToolBar(viewForm,SWT.NONE); viewForm.setTopLeft(toolBar); final ToolItem toolItem = new ToolItem(toolBar,SWT.PUSH); toolItem.setSelection(true); toolItem.setText("打开");
shell.open(); shell.layout(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } }
}
|