【发布时间】:2014-10-18 02:56:16
【问题描述】:
我正在尝试使用 Eclipse 创建一个 Hello World SWT 应用程序。我按照所有说明进行操作,最后我的程序无法运行。
这是我的代码:
import gnu.gcj.xlib.Display;
import org.eclipse.swt.widgets.Shell;
public class HelloWorldSWT {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("Hello world!");
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
}
这是我的错误信息:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The constructor Shell(Display) is undefined
The method readAndDispatch() is undefined for the type Display
The method sleep() is undefined for the type Display
The method dispose() is undefined for the type Display
at HelloWorldSWT.main(HelloWorldSWT.java:13)
有人知道我如何检查问题吗?
【问题讨论】: