1
我有我的刽子手应用的重启按钮,但我对如何重新启动应用程序...谁能给予我正确的想法或指向我朝着正确的方向帮助没有线索?重新启动应用刽子手
public void actionPerformed(ActionEvent e){
// Adds word to Words.txt
if(e.getSource() == btnAddWord){
try{
FileWriter fw = new FileWriter("Words.txt", true);
PrintWriter pw = new PrintWriter(fw, true);
String word = JOptionPane.showInputDialog("Please enter a word: ");
pw.println(word);
pw.close();
}
catch(IOException ie){
System.out.println("Error Thrown" + ie.getMessage());
}
}
// Restarts game
if(e.getSource() == btnRestart){
}
// brings up Help screen
if(e.getSource() == btnHelp){
String message = "The word to guess is represented by a row of dashes, giving the number of letters and category of the word."
+ "\nIf the guessing player suggests a letter which occurs in the word, the other player writes it in all its correct positions."
+ "\nIf the suggested letter does not occur in the word, the other player draws one element of the hangman diagram as a tally mark."
+ "\n"
+ "\nThe game is over when:"
+ "\nThe guessing player completes the word, or guesses the whole word correctly"
+ "\nThe other player completes the diagram";
JOptionPane.showMessageDialog(null,message, "Help",JOptionPane.INFORMATION_MESSAGE);
}
//Exits application
if(e.getSource() == btnExit){
System.exit(0);
}
}
更改应用程序的状态返回到它是什么,当用户启动?我的意思是这里唯一的答案。 – thatidiotguy
为什么重新启动?为什么不在一个while循环中重新初始化hangman框架/窗口,直到按下应该处理的关闭按钮并调用System.exit()。 – Vikdor
我将如何重新初始化框架 –