JFace 技巧集合.

来源:互联网 发布:vegas for mac汉化版 编辑:程序博客网 时间:2024/04/28 10:46
  1. Viewer.setInput方法中不能使用null作为参数, 因为如果使用null, 那么Viewer不会把该参数传递到ContentProvider中.
  2. TableTreeViewer中, 使用TableTree设置布局数据(setLayoutData), 而不是Table.
  3. 使用Dialog时, 设置父shell为调用者的getShell(), 这样当对话框关闭时, 会把焦点返回到调用者上.
  4. TableTreeViewer中Table.getSelectionIndex()选择的位置与getElementAt()中检索的位置不一致. 这可能是个bug.
  5. 继承JFace的Dialog后覆盖buttonPressed(int buttonId)方法时, 最后一步一定要向父Dialog传递该方法(使用super.buttonPressed(buttonId);), 不然open()方法不会返回点击按钮的ID.而是默认的ID(一般为IDialogConstants.OK_ID).
原创粉丝点击