@Test
public void testToolBar(){
Display display= new Display();
Shell topShell= new Shell(display,SWT.SHELL_TRIM|SWT.BORDER);
topShell.setText( "testToolBar" );
topShell.setSize( 800 , 500 );
//不设置布局不显示
topShell.setLayout( new GridLayout());
ToolBar toolBar= new ToolBar(topShell, SWT.NONE);
ToolItem toolItem= new ToolItem(toolBar, SWT.PUSH);
toolItem.setText( "保存" );
ToolItem toolItem2= new ToolItem(toolBar, SWT.PUSH);
toolItem2.setText( "全部保存" );
ToolItem toolItem3= new ToolItem(toolBar, SWT.PUSH);
toolItem3.setText( "打印" );
Text contentText= new Text(topShell, SWT.MULTI|SWT.WRAP);
contentText.setLayoutData( new GridData(SWT.FILL, SWT.FILL, true , true ));
topShell.open();
while (!topShell.isDisposed()){
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
|