请教MessageDialog.openInformation()的错误

来源:百度知道 编辑:UC知道 时间:2024/06/25 22:35:44
import java.io.IOException;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
public class yemian {
public static void main(String[] args){
final Display display = Display.getDefault();
final Shell shell = new Shell();//shell是程序的主窗口
shell.setSize(327,253);
shell.setText("SWT Application");//设置主窗口标题
//------------------------------------------------------------------------
//设值按钮
final Combo combo = new Combo(shell,SWT.READ_ONL

我这里没有swt的jar包没办法帮你测试
首先,类名第一个字母大写 Yemian ,养成好习惯
然后,判断错误你可以用打印日志的方式来判断到底在哪里出错了,哪些值错了。
把null换成"" 试下
MessageDialog.openInformation(shell, "", "选择的Integer对象的值是"+selectObj.toString());

正确应该是显示出 :你选择的integer对象的值是...

这个值是selectObj的值转成的字符串,即(Integer)combo.getData(key)的值,是你获得的,但你是integer型的转成字符串感觉不是用toString,改用 String.valueof(selectObj)试试,或者别抢转成integer型~

MessageDialog.openInformation(shell,"", "选择的Integer对象的值是"+selectObj);

把null换成空串,这样试试,猜的。