今天的学习倍受打击 SWT 问题
刚学 SWT,本以为很简单的,但是运行程序的时候老是有问题,明明没有错误显示,但是运行下面的程序以后只显示了主窗口,不知道怎么回事,心都凉了
public class FenZuKuang {
/**
* @param args
*/
public static void main(String[] args) {
// TODO 自动生成方法存根
final Display display=Display.getDefault();
final Shell shell=new Shell();
shell.setText("服务器管理");
final Composite composite=new Composite(shell,SWT.NONE);
composite.setBounds(20,30,800,500);
//建立三个分组框
// 第一个分组框
final Group group1=new Group(composite,SWT.NONE);
group1.setText("有效更新");
final Button button11=new Button(group1,SWT.RADIO);
button11.setText("等价版本(1.0.1 -> 1.0.2 - 仅服务版本增加) (Q)");
final Button button12=new Button(group1,SWT.RADIO);
button12.setText("兼容版本(1.0.9 -> 1.1.0 - 服务版本和次版本增加) (C)");
//第二个分组框
final Group group2=new Group(composite,SWT.NONE);
group2.setText("更新策略 (U)");
final Label label21=new Label(group2,SWT.NONE);
label21.setText("策略 URL:");
new Text(group2,SWT.NONE);
//第三个分组框
final Group group3=new Group(composite,SWT.NONE);
group3.setText("代理设置");
final Button button3=new Button(group3,SWT.CHECK);
button3.setText("启用 HTTP 代理连接(N)");
final Label label31=new Label(group3,SWT.NONE);
label31.setText("HTTP 代理主机地址: ");
final Text text31=new Text(group3,SWT.NONE);
final Label label32=new Label(group3,SWT.NONE);
label32.setText("HTTP 代理主机端口: ");
final Text text32=new Text(group3,SWT.NONE);
button3.addSelectionListener(new SelectionAdapter(){
public void widgetSelected(SelectionEvent e){
if(button3.getSelection())
{
label31.setEnabled(true);
text31.setEnabled(true);
label32.setEnabled(true);
text32.setEnabled(true);
}
else
{
label31.setEnabled(false);
text31.setEnabled(false);
label32.setEnabled(true);
text32.setEnabled(true);
}
}
});
shell.layout();
shell.open();
while(!composite.isDisposed()){//如果主窗口没有关闭,则一直循环
if(!display.readAndDispatch())//如果主窗口不忙,就让Display处在休眠状态
display.sleep();
}
display.dispose();//释放display资源
}
}