我已经尝试了几种方法来做到这一点......基本上我正在尝试为作业创建一个井字游戏板,也许我遗漏了一些明显的东西,但是当我收到“不是声明”错误时尝试创建按钮。这是我得到的代码:
int rows = 3;
int cols = 3;
JPanel ticTacToeBoard = new JPanel();
ticTacToeBoard.setLayout(new GridLayout(3, 3));
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < cols; j++)
{
JButton gameButton[i] = new JButton[];
ticTacToeBoard.add(gameButton[i]);
}
}
谢谢...