public class HelloWorldSWT {
public static void main(String[] args) {
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:
Display cannot be resolved to a type
Display cannot be resolved to a type
Shell cannot be resolved to a type
Shell cannot be resolved to a type
at HelloWorldSWT.main(HelloWorldSWT.java:10)我是Java新手,我已经尝试过了,但仍然不能工作:
指令告诉我:你会得到编译错误。在Java编辑器中单击鼠标右键,选择Source > Organize Imports,然后保存更改。
发布于 2012-08-17 02:22:41
首先,您必须将适当的库添加到您的项目(swt-gtk-x.y.jar中。
然后,您的IDE将有可能为您定义适当的导入。
https://stackoverflow.com/questions/11993060
复制相似问题