`
brofe
  • 浏览: 229912 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

SWT/JFace 扩展ApplicationWindow的StatusLineManager

    博客分类:
  • Java
 
阅读更多
在使用JFace时,如果继承ApplicationWindow对象,你就能立即获得一个含菜单(MenuManager),工具栏(ToolBarManager)、状态栏(StatusLineManager)的应用窗口。

本文主要介绍如何扩展状态栏(StatusLineManager),有时候我们会在状态栏中加入:当前登录用户信息、内存使用信息等等小控件。

当继承ApplicationWindow对象并实现一下方法后,即可创建状态栏(StatusLineManager)
@Override
	protected StatusLineManager createStatusLineManager() {
		statusLineManager = new StatusLineManager() {
			
			@Override
			public void setErrorMessage(String message) {
				if (statusLineManager != null) {
					statusLineManager.setErrorMessage(ImageFactory.get(Constants.ERROR_IMAGE_KEY), message);
				}
			}
			
			@Override
			public void setMessage(String message) {
				if (statusLineManager != null) {
					statusLineManager.setMessage(ImageFactory.get(Constants.SUCCESS_IMAGE_KEY), message);
				}
			}
		};
        return statusLineManager;
    }


只要从StatusLineManager对象中获取Control便能扩展,伪代码如下:
final Composite statusComposite = (Composite)statusLineManager.getControl();
		
final Composite composite = new Composite(statusComposite, SWT.LEFT_TO_RIGHT);
GridLayout gl = new GridLayout(1, false);
gl.marginHeight = 1;
composite.setLayout(gl);

CLabel label = new CLabel(composite, SWT.NONE);
label.setText("当前登录用户...");


效果图见附件。

  • 大小: 60.9 KB
分享到:
评论
2 楼 brofe 2012-02-24  
宏基小键盘 写道
这个好象是不行的吧,statusLineManager.getControl()已经有三个子控件了,一个是CLabel,一个是ToolBar,一个是Compasite,现在再加一个,位置会乱的。能分享一下图片效果的源码吗?



图片就在附件啊。。
1 楼 宏基小键盘 2012-02-19  
这个好象是不行的吧,statusLineManager.getControl()已经有三个子控件了,一个是CLabel,一个是ToolBar,一个是Compasite,现在再加一个,位置会乱的。能分享一下图片效果的源码吗?

相关推荐

Global site tag (gtag.js) - Google Analytics