i am developing a new Hangman game for school assignment. The game is working fine for the first time. If user clicks on the Button Try Again , to try one more time, computer randomly picks up another String.When i try to update the JLabel with the New String. Its not Happening.
There is a string in my code
"private String populateDashes = "";"
populateDashes String is used to print Dashes in JPanel something like in this (-----). This is based on the String length. This works fine for first time, however when the User try to play agai, the Label is not getting updated with the new String. Can some help me out with this.
This works fine for first time, however when the User try to play agai, the Label is not getting updated with the new String. Can some help me out with this.
You are not restarting the game you are creating a new Hangman3 object but you aren't displaying it (or closing the original one) so what you can see is the original Hangman3 GUI.
BTW this is not the way to handle a play again request. You need to separate your GUI initialisation code (creation of GUI components) from your game code (populating of values) so you can restart the existing Hangman3 game by selecting a new word and calling the game code again.
posted 6 years ago
Thanks. I have to change a lot of things to make it work.