• Post Reply Bookmark Topic Watch Topic
  • New Topic

Disable and enable buttons based on menu item chosen

 
Trevor Donaldson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

I am building a simple hangman game and have run into some trouble. I am able to reset all of my instance variables if a new game is chosen from the menu bar but I am unable to enable all of the buttons again (The buttons are disabled if they are chosen while the game is being played).

Below is the code that I am using for my GUI. I want to enable all of the buttons again if the user chooses New from the menu. If any more information is needed I will provide it.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
create a reset method which initialises all your variables, and enables all your buttons.
(I presume the buttons are the letters, so it would be simpler if they were a button array)

call reset():
1) when the game first starts
2) when 'New Game' is selected
 
Trevor Donaldson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hate to be a pain as I am somewhat a newbie to this. Could you give me an example?
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here's a simple demo for the buttons - just click any/many of the buttons
and they will be disabled, then click 'New Game' to re-enable them.

in this e.g. calling reset in the constructor is not necessary, but in your
game, if you have any variables that need to be initialised with a non-default
value, the method will need to be called.

 
Trevor Donaldson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
AAAAAHHHHH!!! Said the blind man. Thank you very much.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!