I am basically trying to make a TicTacToe game in Netbeans GUI builder. I have nine(3x3) buttons to show a grid for the game and that's where you mark X and O's. I want to make it one player game.
I wanted to know how to make an array of buttons(JButton).?It is needed to conveniently flip over different buttons.
In the game, computer would need to play with another player and has to mark O and X randomly across nine buttons. So , can you pls also tell me how to randomly shuffle over elements in button array and choose a button that is not currently marked, which would be used by computer player to mark his turn.?
I have not started with the code yet, so i am giving any sample code. Your help would be greatly appreciated. Pls help
utkarshsahu
0
Newbie Poster
Recommended Answers
Jump to Postchoose a button that is not currently marked
When you chose a button, test if it is marked (how are you marking the buttons) and if it is marked, chose another one.
how to randomly shuffle over elements in button array
Use the Random class to …
Jump to Postjust my 2 cents but when i wanted to make a tictactoe game, i found that the buttons were not very elegant for that!
what i did, and keep in mind this is just a suggestion, or a challenge if you want, is simply add a JPanel to my JFrame, …
All 6 Replies
NormR1
563
Posting Sage
Team Colleague
Philippe.Lahaie
42
Posting Whiz in Training
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
DavidKroukamp
105
Master Poster
Team Colleague
Featured Poster
Philippe.Lahaie
42
Posting Whiz in Training
utkarshsahu
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.