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 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, …
Jump to PostYes, the default appearance of buttons is not good for this application, but it's easy to change that. For example a quick button.setMargin(new Insets(0, 0, 0, 0)); will leave you with a simple plain rectangle. Then you can still use button.setText("X"), or setIcon for a snazzier look wthout any …
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.