SWT 在linux下 Combo出现异常
来源:互联网 发布:网络h十是什么意思啊 编辑:程序博客网 时间:2024/06/16 08:13
因为同时在suse和windows xp 下开发Eclipse Plug-in.发现一样的代码,在不同的操作系统中的表现也不一样。最后发现是Combo控件的表现不一致。以下是发现问题的代码:
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ControlContribution;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
class ComboContribution extends ControlContribution {
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public ComboContribution(String id) {
super(id);
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
@Override
protected Control createControl(Composite parent) {
final Combo combo = new Combo(parent, SWT.NONE);
combo.setItems(new String[] { "Jurassic Park", "E.T.", "JAW" });
combo.addModifyListener(new ModifyListener() {
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public void modifyText(ModifyEvent e) {
String text = combo.getText();
System.out.println("========== " + text);
}
});
// combo.addSelectionListener(new SelectionAdapter() {
// public void widgetSelected(SelectionEvent e) {
// String text = combo.getText();
// System.out.println("========== " + text);
// }
// });
return combo;
}
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
public class TestToolBar {
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public TestToolBar(Shell shell) {
IAction runAction = new Action("Run") {
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public void run() {
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
}
};
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ToolBarManager barManager = new ToolBarManager(SWT.NONE);
barManager.add(runAction);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ComboContribution combo = new ComboContribution("Combo.contribution");
barManager.add(combo);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
barManager.createControl(shell);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
barManager.getControl().setLayoutData(gd);
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/**
* DOC qianbing Comment method "main".
*
* @param args
*/
public static void main(String[] args) {
Display display = new Display();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
final Shell shell = new Shell(display);
shell.setLayout(new GridLayout());
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
new TestToolBar(shell);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
shell.setSize(300, 300);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
Combo加入ModifyListener后,在Windows下是使用正常,但是在Suse下,监听器被调用了2次。而且第一次调用取得的Combo.getText()是“”,第二次才正常。严重影响了程序的流程。后来决定使用SelectionListener, 在在Windows下每次选择都会调用监听器,但是在Suse下,只有选择不同的选项,才会调用监听器。因为SWT是调用操作系统本地控件,所以各个操作系统的表现很可能有出入,其可移植性还是有待提高。
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
- SWT 在linux下 Combo出现异常
- SWT 在linux下 Combo出现异常
- SWT 在linux下 Combo出现异常
- SWT 在linux下 Combo出现异常
- 在SWT中实现自绘Combo
- SWT Combo 定义
- 扩展swt combo
- SWT组合框Combo
- SWT之Combo的使用
- 导致在Debug下没有异常在 Release 下却出现异常的代码
- 制作支持多选的 SWT Combo
- 在derby数据库下使用hibernate出现的异常
- tomcat在linux下出现乱码问题
- Linux下DateFormat的parse方法出现”ParseException”异常
- Linux下DateFormat的parse方法出现”ParseException”异常
- linux 下tomcat 6 启动出现日志异常
- 在SWT下实现BorderLayout布局
- windows下编辑脚本文件在linux下出现错误
- 再谈:Norton误报WinXP事件的技术分析 二
- @Resource 資源取得 JNDI 的相關資源
- VB.NET and C# 语法比较手册
- [概念] Nominal Group Analysis
- MS CRM Customization - 在CRM Web中添加按钮及集成扩展程序
- SWT 在linux下 Combo出现异常
- Provide an Alternative View to Data Using Splitter Window铪
- How to create a read-only user in TFS source control
- 让我们摒弃一些浮躁 -- 对Norton误报WinXP事件的技术分析
- [概念] Force Field Analysis
- 一个开源的IoC采集服务器体系结构设计
- 为ToolBarManager添加自定义控件
- Chapter 1 初見 EJB3.0 (2)
- 使用 Web service 的站点列表