0

I made a tic-tac-toe game using swing and a Jpanel. I got it to check for a winner. Now that I have a winner though, I don't want the user to be able to keep putting down more pieces in the game (even if there is room for pieces).

Here I have the last bit of code where _board represents the 3 x 3 board:

if (_board.testcrossDownwards() || _board.testcrossUpwards() || _board.testTopRow() || _board.testMiddleRow() || _board.testBottomRow() ||
            _board.testLeftColumn() || _board.testMiddleColumn() || _board.testRightColumn()) {
        _message.setText(player_name + " wins!");

    } else if (_board.isTicTacRunThru()) {
        _message.setText("It's a DRAW!");
    } else {
    _message.setText("You clicked on " + s.getCoordString() +". " + next_player_name + " to play.");
    } 

I assume that the piece that I need to add will follow the player_name + " wins!" line.

  • What kind of components are you using? – JoeChris Apr 06 '20 at 04:44
  • I'm super inexperienced but I think JPanels, JFrame and JLabels? – Antonio Pano Apr 06 '20 at 04:48
  • yeah sure but how are you getting user input, like jbuttons? most swing components have a .setEnabled() method, you can probably use that in some way -- but its hard for us to answer your question without seeing the code – JoeChris Apr 06 '20 at 04:51

0 Answers0