public static void board(){ //Create's my board
{
JFrame board = new JFrame();
board.setSize(400, 200 );
board.setTitle("Quiz Board Game");
Container pane = board.getContentPane();
pane.setLayout(new GridLayout(rows, columns));
Color temp;
for (int i = 0; i < rows; i++)
{
if (i%2 == 0)
{
temp = col1;
}
else
{
temp = col2;
}
for (int j = 0; j < columns; j++)
{
JPanel panel = new JPanel();
panel.setBackground(temp);
if (temp.equals(col1))
{
temp = col2;
}
else
{
temp = col1;
}
pane.add(panel);
}
}
board.setVisible(true);
我有这个用java编写的代码,我想知道如何添加两个圆圈以便创建一个有两块的板?谢谢。
PS我是java新手