请有人给我一个使用 java acm 包创建包含正方形(或按钮)网格的 GUI 的示例。
问问题
350 次
2 回答
0
您可以使用方形框来创建网格
GRect []grect = new GRect[rows][colums];
for(int i=0; i<rows; i++){
for (int j=0; j<colums; j++){
grect[i][j] = new GRect(x, y, width, height); //here x and y are the x,y coordinates of the box
// widht and height are the width and height of the box
add(grect[i][j]);
}
}
有关更多详细信息,请点击此链接
于 2014-07-15T05:19:47.957 回答
0
我认为使用 GRect 将正方形添加到 JFrame 是不可能的,无论如何都可以这样做。首先你必须把你的类扩展到 GraphicsProgram,像这样
公共类 your_class 扩展 GraphicsProgram{
//here you can create the grid as I mentioned above
}
于 2014-07-15T05:43:22.550 回答