Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JLabel help pls  RSS feed

 
rui natal
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i'm making a tic-tac-toe game and I need to know when the player clicks any of the buttons becausa I need to call a function that will make the computer play next, i have a class named Casa with a JButto in a JLabel and i have another class that creats 9 Casa and puts them in a JLabel and know I need to know when someone clicks one of those 9 Casa, no matter wich because in the class Casa i already change the image of the button when he's clicked...

I appreciate any help you can give me

PS: sorry about the bad english, i'm portuguese
 
Krisp Sigh
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Follow these four steps for your game.

1)when u click on the button first check if its already occupied or not
if its not assigned any value put the relevant image on the button.

2)now check for the win condition for the user.
ie. 3 in a row or 3 in diagonally

3)choose a place to put the Computer's turn

4)now check if computer wins the game
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post some code snippets. This will give us the details we need to help understand what you are doing. We will be glad to help you from there.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!