0

グリッドレイアウトの指定された場所に JButton を追加しようとしていますが、これを行う方法がわかりません。

public void addButtons()
    {
        myBoard = myController.getMyBoard();
        for (int i = 0; i < this.getEntryInt(); i++)
        {
            for(int j = 0 ; j < this.getEntryInt(); j++)
            {


                if(myBoard[i][j]==true)
                {
                    buttons[i][j] = new JButton("Q"); // error: The type of the expression must be an array type but it resolved to JButton

                }
            }
        }
    }

グリッド レイアウトの特定のプロットにボタンを追加する方法はありますか?

4

1 に答える 1

1

コンポーネントを に配置する場所を選択することはできませんGridLayout。順次追加予定です。

代わりにGridBagLayoutを使用してみてください。

于 2013-11-09T20:57:06.277 に答える