我正在制作一个小游戏和小游戏。交叉,然后在5转后,会弹出confirmdialog,询问您是否要继续播放或重置电路板。 no选项重置电路板,yes选项使确认对话框关闭,没有其他任何事情发生。我已经完成了No选项但不知道如何做yes选项。
这是我的确认对话框的代码:
int j = JOptionPane.showConfirmDialog(null, "het wordt waarschijnlijk gelijkspel. toch doorspelen?", "Doorgaan(Y) of stoppen(N)?", JOptionPane.YES_NO_OPTION);
if(j == JOptionPane.NO_OPTION)
{
for(int i = 0; i < buttons.length; i++)
{
buttons[i].setText("");
buttons[i].setEnabled(true);
teller = 0;
}
}
if (j == JOptionPane.YES_OPTION)
{
// close the confirm dialog and nothing else happens
}
非常感谢任何帮助:)
答案 0 :(得分:0)
根据您的描述:
no选项重置电路板,yes选项使确认对话框关闭,没有其他事情发生
所以你可以删除else部分来保持按钮的状态:
int j = JOptionPane.showConfirmDialog(null, "het wordt waarschijnlijk gelijkspel. toch doorspelen?", "Doorgaan(Y) of stoppen(N)?", JOptionPane.YES_NO_OPTION);
if(j == JOptionPane.NO_OPTION)
{
for(int i = 0; i < buttons.length; i++)
{
buttons[i].setText("");
buttons[i].setEnabled(true);
teller = 0;
}
}