2012-04-08 87 views
0

我创建了一个Dialog有两个按钮是,否,然后我有动作监听器添加到他们,我的问题是,我想没有按钮来隐藏我已经创建了Dialog隐藏对话框从里面LWUIT

代码的样子:

dialog = new Dialog(title); 
     dialog.setDialogType(Dialog.TYPE_CONFIRMATION); 

     ta = new TextArea(text); 
     ta.getStyle().setBorder(Border.createEmpty()); 
     ta.setEditable(false); 
     yesCommand = new Button("YES"); 
     noCommand = new Button("NO"); 

     yesCommand.addActionListener(new ActionListener() { 

      public void actionPerformed(ActionEvent ae) { 
       LGBMainMidlet.getLGBMidlet().notifyDestroyed(); 
      } 
     }); 

     noCommand.addActionListener(new ActionListener() { 

      public void actionPerformed(ActionEvent ae) { 
       Logger.Log("Bye Bye"); 
       dialog = null; 
       System.gc(); 
      } 
     }); 

     dialog.addComponent(ta); 
     dialog.addComponent(yesCommand); 
     dialog.addComponent(noCommand); 
     dialog.show(); 

代码不为我工作,谁能告诉我是什么问题?

B.N.我已经使用dialog.dispose(),但它退出整个应用程序

+0

但是,你想要的是当你按下一个命令或什么时隐藏对话框? – Mun0n 2012-04-08 16:54:33

回答

1

Dialog.dispose()不会退出整个应用程序,它只是关闭对话框。 如果您的应用程序中没有任何内容,您可能会看不到任何对象。

+0

它的工作原理,我有问题,当我解决它的处置方法工程 – 2012-04-29 14:41:00

2

最好使用 dialog.setTimeout(1000);该数字显示对话框以毫秒为单位等待的时间限制。所以通过这样做可以自动退出对话框。