package edu.ch4;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.*;
public class Jiemian extends Shell {protected void checkSubclass() {
// Disable the check that prevents subclassing of SWT components
}public Jiemian(Display display)
{
super(display, SWT.SHELL_TRIM);Label lb1=new Label(this,SWT.NONE);lb1.setText("请输入姓名:");
lb1.setBounds(20,50,70,20);
final Text text1=new Text(this,SWT.BORDER);
text1.setBounds(100,49,70,20);Label lb2=new Label(this,SWT.NONE);lb2.setText("请输入年龄:");
lb2.setBounds(20,100,70,20);
final Text text2=new Text(this,SWT.BORDER);
text2.setBounds(100,100,70,20);
Button bt=new Button(this,SWT.NONE);
bt.setBounds(20,150,70,20);
bt.setText("确定");
 
bt.addSelectionListener(new SelectionAdapter(){
public void widgetSelected(SelectionEvent e){
MessageBox dialog=new MessageBox(this,SWT.OK|SWT.ICON_INFORMATION);
dialog.setText("组件选择事件");
dialog.setMessage("您的姓名是:"+text1.getText()+"您的年龄是:"+text2.getText());
dialog.open();
}
});Button bt1=new Button(this,SWT.NONE);
bt1.setBounds(100,150,70,20);
bt1.setText("重置");
 
bt1.addSelectionListener(new SelectionAdapter(){
public void widgetSelected(SelectionEvent e){
text1.setText("");
text2.setText("");}
}
);
}
public static void main(String[] args)
  {
 
   
Display display = Display.getDefault();
  final Jiemian shell=new Jiemian(display);
  shell.setText("系统登录");
  shell.setSize(300, 300);
  shell.layout();
     shell.open();
  while(!shell.isDisposed())
  {
display.sleep();
if(!display.readAndDispatch())
{}
  }
  
  display.dispose();
  }
   
   
}
里面的MessageBox dialog=new MessageBox(this,SWT.OK|SWT.ICON_INFORMATION);
提示构造函数 MessageBox(new SelectionAdapter(){}, int)未定义