Eclipse初学遇到的问题
package com.swtdesigner;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class HelloWorld {
/**
* 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( "SWT Application ");
//
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
}
Exception in thread "main " java.lang.Error: Unresolved compilation problems:
Display cannot be resolved to a type
Display cannot be resolved
Shell cannot be resolved to a type
Shell cannot be resolved to a type
新建的一个SWT的程序,只是一个窗口,文件前面有许多小红叉,编译出错,为什么
[解决办法]
上面提示的几句话,都没有定义,你怎么能引用?好好看看java书
[解决办法]
鼠标移到红叉上面.按F2看看错误提示
[解决办法]
没把包导入到项目里
[解决办法]
我也遇到同样的问题了,包(org.eclipse.swt.win32.win32.x86_3.2.0.v3232m.jar)我也导入了,但还是出现这样的问题,为什么呢?
我的eclipse是3.2的,SWT Designer是6.6.0
安装的时候没有问题,但是包导进去了可跟没倒一样,这是怎么回事儿呢?
[解决办法]
偶也一样了....
等待着高手的解答了...
[解决办法]
Display 和Shell 不能被解析,你确定SWT插件被加到Eclipse中了吗?
鼠标移到红叉上面。把问题的提示贴出来看一看啊。
[解决办法]
你用ECLIPSE吗?那就下载个SWT的包,再配置build path中的libraries就好了.
你的那段CODE还有个问题,最后还要添一句display.dispose();不然可能会造成内存泄漏之类的事.
[解决办法]
build path 没有包