MyException - 我的异常网
当前位置:我的异常网» Eclipse » 这边每次都是在messagedialog这里卡住了,求解

这边每次都是在messagedialog这里卡住了,求解

www.MyException.Cn  网友分享于:2013-12-09  浏览:174次
这里每次都是在messagedialog这里卡住了,求解
import java.security.MessageDigest;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;


import com.sun.corba.se.impl.protocol.giopmsgheaders.Message;
import com.sun.corba.se.impl.protocol.giopmsgheaders.Message_1_0;

import sun.misc.resources.Messages;
import sun.misc.resources.Messages_zh_CN;

/**
 * 
 */

/**
 * @author joycexu
 * 
 */
public class helloworld {

/**
* @param args
*/
public static void main(String[] args) {
final Composite shell;
// TODO Auto-generated method stub
final Combo combo =new Combo(shell,SWT.READ_ONLY);
combo.setBounds(16, 11, 100, 25);
final Button button1=new Button(shell,SWT.NONE);
button1.setBounds(17, 65, 100, 25);
button1.setText("设值");
button1.addSelectionListener(new SelectionAdapter(){
public void widgetSelected (SelectionEvent e){
combo.removeAll();
for(int i=1;i<=10;i++)
combo.add("第"+i+"个字符串");
combo.select(0);
}


});
final Button button2=new Button(shell,SWT.NONE);
button2.setBounds(136, 66, 100, 25);
button2.setText("取值");
button2.addSelectionListener(new SelectionAdapter(){
public void widgetSelected(SelectionEvent e){
MessageDialog.openInformation(shell,null,combo.getText());

}

});

});
}


------解决方案--------------------
首先在这里给楼主个简单的关于SWT开发的列子:
Java code
package test;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class August_20_HellWorld
{
  public static void main(String[] args)
  {
    // display负责管理实践循环和控制UI线程和其他线程之间的通信
    final Display display = Display.getDefault();
    final Shell shell = new Shell();// Shell是程序的主窗口
    shell.setSize(400, 400);// 设置主窗口的大小
    shell.setText("SWT Aplication");// 设置主窗口的标题
    shell.layout();// shell应用界面布置
    shell.open();// 打开Shell主窗口
    while (!shell.isDisposed())// 如果主窗口没有关闭,则一直循环
    {
      if (!display.readAndDispatch())// 如果display不忙
      {
        display.sleep();// display休眠
      }
    }
  }
}

文章评论

软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有