0
試圖創建一個joptionpane來運行任何想法,爲什麼這不起作用?JOptionPane發生故障並使其工作
public void playerLost() {
if(player.getStaminaLevel() < player.getStaminaNeededToMove(Terrain.SAND)) {
JOptionPane.YES_NO_OPTION(
if (JOptionPane.NO_OPTION) {
dispose();
}
else
{
game = new Game();
createGridSquarePanels();
update();
}
}
我也試過,但說JOptionPane.NO_OPTION不能從int轉換爲字符串
public void playerLost() {
if(player.getStaminaLevel() < player.getStaminaNeededToMove(Terrain.SAND)) {
int choice = JOptionPane.showConfirmDialog(
this,
"sorry you lost\nWould you like to restart?",
JOptionPane.YES_NO_OPTION,
JOptionPane.INFORMATION_MESSAGE);
if (choice == JOptionPane.NO_OPTION) {
dispose();
}
else
{
game = new Game();
createGridSquarePanels();
update();
}
}
}