java循环棋盘标签

rbl8hiat  于 2021-07-08  发布在  Java
关注(0)|答案(0)|浏览(245)

我想在棋盘的顶部和底部标上a-h,在左右两侧标上1-8。这就是我现在的标签:add(newglabel(“+((char)(i+65)+)”),x,y));当然,它不会在顶部和底部贴标签,而是在每个瓷砖上贴标签。如何在循环中创建字母而不在每个图块中显示它们?
这是(int i=0;i<numrows;i++){

for (int j = 0; j < numColumns; j++) {

            // Calculates the position of the tiles

            double x = j * squareSize + 100;
            double y = i * squareSize + 100;

            // Draws the square

            GRect square = new GRect(x, y, squareSize, squareSize);

            square.setFilled((i + j) % 2 != 0);
            add(square);

            // Labeling the top and bottom with A-H + left and right from 1 to 8

                add(new GLabel("" + ((char) (i + 65) + ""), x, y));

                num++;
            }
        }
    }

谢谢!

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题