2013-03-12 60 views
1

我做了一個對話框,其中有一些按鈕。代碼名稱1中按鈕動作的關閉對話框

按鈕之一的動作我想完成對話框。

我不想在其中添加任何命令。

請幫忙。

這是我的代碼。

Form form = (Form) createContainer("/theme", "MYDialog1"); Container container = (Container) findByName("Container", form); button = new Button(new Command("Close"),i)); try { button.setUIID("LabelButton"); } catch (Exception exception) { exception.printStackTrace(); } button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { ?????? } }); container.addComponent(button); Dialog.show("", form, null);

回答

4

如果您將命令添加到對話框,它將默認處理該對話框。

您可以手動調用dialog.dispose()關閉對話框,使當前對話框正確使用Dialog dlg = (Dialog)Display.getInstance().getCurrent();

0

你不對話和容器之間的關係。因爲這個原因你不能處理對話。

我從你的問題中瞭解到,你不會使用命令,因爲你想要你的GUI按鈕。

我的建議是建立這樣的對話(我認爲是可以工作):

Dialog dialog = new Dialog(); 
    Display.getInstance().callSerially(new Runnable() { 
     public void run() { 
      dialog.setLayout(new BoxLayout(BoxLayout.Y_AXIS)); 
      ... 
      dialog.addComponent(dialog); 

      button = new Button(new Command("Close"),i)); 
      try 
      { 
       button.setUIID("LabelButton"); 
       } 
      catch (Exception exception) 
      { 
      exception.printStackTrace(); 
      } 
      button.addActionListener(new ActionListener() 
       { 
        public void actionPerformed(ActionEvent evt) 
        { 
         dialog.dispose();//??????????? 
        } 

      dialog.addCommand(okCommand); 
      ... 
      dialog.show(); 
     } 
    }); 

此對話框需要被集體成員通過按鈕來確認。

相關問題