2011-10-22 59 views
1

我已經生成了一個JDialog在以下線路上使用JOption C'tor的:如何提取從JDialog按下的按鈕?

Object[] options = 
      { 
     "Yes", "No (Exit to main menu)" 
     }; 
     JOptionPane messagePane = new JOptionPane(i_StringMessage+"\nDo you want to begin another Net Game?", JOptionPane.INFORMATION_MESSAGE, JOptionPane.YES_NO_OPTION, null, options); 
     messagePane.setLocation(500, 1000); 
     JDialog dialog = messagePane.createDialog(m_GameApplet.GetJpanelStartNetGame(), "Game over"); 
     m_GameApplet.GetJpanelStartNetGame().SetPopUpWindowReference(dialog); 
     m_GameApplet.GetJpanelStartNetGame().GetPopUpWindowReference().setVisible(true); 

我設置的JDialog是可見的,但我不知道我怎麼現在可以接收並解析按鈕的用戶點擊,以類似的方式來使用靜態JOption功能類似:

int userChoice = JOptionPane.showOptionDialog(this, i_StringMessage+"\nDo you want to begin another Net Game?", 
       "Game over", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[0]); 

如何關閉JDialog的,又是什麼配置功能excately嗎?
感謝

+0

爲了更好地提供幫助,請發佈[SSCCE](http://sscce.org/)。 –

+0

請學習java命名約定並堅持使用它們 – kleopatra

回答