如何阻止用户在打开面板后继续使用 JPanel?

huangapple 未分类评论50阅读模式
英文:

How do I stop a user from using a JPanel after it has opened?

问题

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

} else if (_board.isTicTacRunThru()) {
    _message.setText("平局!");
} else {
    _message.setText("你在" + s.getCoordString() + "点击了。 轮到 " + next_player_name + " 下棋。");
}
英文:

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.

huangapple
  • 本文由 发表于 2020年4月6日 12:40:02
  • 转载请务必保留本文链接:https://java.coder-hub.com/61053078.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定