`

ViewForm

 
阅读更多

      ViewForm是一个容器,它是编辑器的基座,用来容纳工具栏和文本框,ToolBar是一个工具栏,同时可以容纳一个工具栏按钮ToolItem

 

		ViewForm vf=new ViewForm(shell, SWT.NONE);
		vf.setLayout(new FillLayout());
		
		final Text text=new Text(vf, SWT.BORDER|SWT.V_SCROLL);
		vf.setContent(text);
		
		ToolBar tb=new ToolBar(vf, SWT.NONE);
		ToolItem ti=new ToolItem(tb, SWT.PUSH);
		ti.setText("取得");
		ti.addSelectionListener(new SelectionAdapter()
		{
			@Override
			public void widgetSelected(SelectionEvent arg0) {
				// TODO Auto-generated method stub
				MessageDialog.openInformation(null, null, text.getText());
			}
			
		});
		
		
		ToolItem ti2=new ToolItem(tb, SWT.PUSH);
		ti2.setText("删除");
		ti2.addSelectionListener(new SelectionAdapter()
		{
			@Override
			public void widgetSelected(SelectionEvent arg0) {
				text.setText("");
			}
			
		});
		
		vf.setTopLeft(tb);
 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics