问题描述
最近学习java,在viewform上创建了一个toolbar,在toolbar上创建两个toolitem,程序运行时怎么不显示呢?程序代码如下:importorg.eclipse.swt.SWT;importorg.eclipse.swt.custom.ViewForm;importorg.eclipse.swt.layout.FillLayout;importorg.eclipse.swt.widgets.Display;importorg.eclipse.swt.widgets.Shell;importorg.eclipse.swt.widgets.Text;importorg.eclipse.swt.widgets.ToolBar;importorg.eclipse.swt.widgets.ToolItem;publicclassTest{/***Launchtheapplication*@paramargs*/publicstaticvoidmain(String[]args){finalDisplaydisplay=Display.getDefault();finalShellshell=newShell();shell.setSize(565,445);shell.setText("SWTApplication");//shell.setLayout(newFillLayout());finalViewFormviewForm=newViewForm(shell,SWT.NONE);viewForm.setLayout(newFillLayout());finalToolBartoolBar=newToolBar(viewForm,SWT.NONE);viewForm.setTopLeft(toolBar);finalToolItemnewItemToolItem=newToolItem(toolBar,SWT.PUSH);newItemToolItem.setText("取得");finalToolItemnewItemToolItem_1=newToolItem(toolBar,SWT.PUSH);newItemToolItem_1.setText("清除");finalTexttext=newText(viewForm,SWT.BORDER);viewForm.setContent(text);shell.layout();shell.open();while(!shell.isDisposed()){if(!display.readAndDispatch())display.sleep();}}}
解决方案
解决方案二:
有没有类似于setVisible(true)这样的方法可供调用?
解决方案三:
MARK