我已经使用JOption C&C生成了一个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,以及dispose函数可以做什么? 谢谢
答案 0 :(得分:1)
请参阅以下链接中的“直接使用:”部分:
http://download.oracle.com/javase/1.4.2/docs/api/javax/swing/JOptionPane.html
您需要使用JOptionPane的getValue()
获取所选值并进行相应的解析。