主题:[原创]应用程序运行结果不正确?
内 容 预 览
一应用程序:
/**@author WangJinTao,MengQingChang 2006
*/
package event;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.jface.dialogs.*;
public class ListenerExample {
public static void main(String[] args) {
final Display display = Display.getDefault();
final Shell shell = new Shell();
shell.setSize(200, 120);
shell.setText("监听器实例");
Button button = new Button(shell, SWT.PUSH);
button.setBounds(35, 25, 120, 25);
button.setText("确定");
button.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
MessageDialog.openInformation(shell, null, "HelloWorld!!");
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
}
运行结果应该是:
出现一窗口,点击确定.出现一对话框.
而实际上呢是:
出现一窗口,点击确定按钮,程序结束,窗口也消失(任务栏上不显示),在控制台上出现以下语句:
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/core/runtime/IStatus
at event.ListenerExample$1.widgetSelected(ListenerExample.java:22)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:90)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3348)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2968)
at event.ListenerExample.main(ListenerExample.java:32)
Caused by: java.lang.ClassNotFoundException: org.eclipse.core.runtime.IStatus
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 7 more
请各位高位指教:
我的email是xtcqpgff@yahoo.com.cn
QQ:331643573
一应用程序:
/**@author WangJinTao,MengQingChang 2006
*/
package event;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.jface.dialogs.*;
public class ListenerExample {
public static void main(String[] args) {
final Display display = Display.getDefault();
final Shell shell = new Shell();
shell.setSize(200, 120);
shell.setText("监听器实例");
Button button = new Button(shell, SWT.PUSH);
button.setBounds(35, 25, 120, 25);
button.setText("确定");
button.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
MessageDialog.openInformation(shell, null, "HelloWorld!!");
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
}
运行结果应该是:
出现一窗口,点击确定.出现一对话框.
而实际上呢是:
出现一窗口,点击确定按钮,程序结束,窗口也消失(任务栏上不显示),在控制台上出现以下语句:
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/core/runtime/IStatus
at event.ListenerExample$1.widgetSelected(ListenerExample.java:22)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:90)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3348)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2968)
at event.ListenerExample.main(ListenerExample.java:32)
Caused by: java.lang.ClassNotFoundException: org.eclipse.core.runtime.IStatus
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 7 more
请各位高位指教:
我的email是xtcqpgff@yahoo.com.cn
QQ:331643573