写了个小程序,代码如下:
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import java.awt.event.*;
import java.awt.*;
import org.eclipse.jface.dialogs.*;public class HelloWorld { private static Text helloworldText;
/**
 * Launch the application
 * @param args
 */
public static void main(String[] args) {
final Display display = Display.getDefault();
final Shell shell = new Shell();
shell.setSize(500, 375);
shell.setText("SWING");
// shell.open(); helloworldText = new Text(shell, SWT.BORDER);
helloworldText.setText("helloworld");
helloworldText.setBounds(71, 64, 100, 25);
        出错位置:helloworldText.addMouseListener(new MyMouseDoubleClick());
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}

private static final class MyMouseDoubleClick extends MouseAdapter{
public void mouseDoubleClick(MouseEvent e){
MessageDialog.openInformation(null,"","HELLOWORLD");
}
}}eclipse在程序中出错位置提示:
类型 Control 中的方法 addMouseListener(MouseListener)对于参数
 (HelloWorld.MyMouseDoubleClick)不适用但是我觉得内部类是继承了MouseAdapter类,而MouseAdapter又实现了MouseListener接口,那为什么会出现这样的错误,烦请帮我解惑~~

解决方案 »

  1.   

    你用的是swt吧,没用过,不知道swt和swing/awt的事件通不通用.
      

  2.   

    除非你为Eclipse开发插件,否则不要用SWT。现在Swing除了启动速度有点慢,其他任何一点都比SWT好,何苦呢。
      

  3.   

    我也觉得SWT机制不是很好
    你既然做JAVA了就是为了兼容性 让每个平台都能运行
    但是SWT是最小公倍数做法,他的最大确定就是兼容性差为何不用兼容性好的SWING而去用SWT