java - Tic Tac Toe Game -
I am making a tick tac toe game in Java for personal learning purposes, and I Trying to change when the button is clicked, then "o" button from "". Obviously I am not going to go about it properly and some suggestions would be greatly appreciated.
When I run the code, I get the error "on java.tv.tvvvtvtmtmtxt". P>
// Graphics, buttons and frames import is included java.awt. *; Import java.awt.event.MouseAdapter; Import java.awt.event.MouseEvent; Import javax.swing *; Public static pocket [] [] B = new pocket [3] [3]; Public Stable Zero Playersmove () {b [0] [0] .addMouseListener (New MouseAdapter) {Public Zero Mouseclatic (Mouse Event E) {String Text = B [0] [0] .gate Text (); ("-") {b [0] [0] .setText ("O"); // computerMove ();} and {System.out.println ("choose again"); playerMove ();}} }); }
What you want to do is set up a listener in the beginning, Not to call playerMove to call. So something like that public stable pocket [] [] B = new pocket [3] [3]; {// initial code b [0] [0] .addActionListener (new executor () {executed public zero verb (action event e) {string text = b [0] [0] [0] .gate text (); if (Text angle "-")) {b [0] [0] .set text ("o"); Computermove ();} and {System.out.printLine ("choose again");}}}); // and for the other 8 buttons} Of course, you want to use a loop instead of repeating the same code 9 times, but as you say, this is another issue is.
Comments
Post a Comment