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,然后保存您的更改。