Merge remote-tracking branch 'origin/master'

This commit is contained in:
zhe 2021-11-11 14:45:35 +01:00
commit 124a4649b0

View File

@ -9,7 +9,8 @@ import javax.swing.Timer;
public class Board extends JPanel public class Board extends JPanel
{ {
public static final int BOARD_WIDTH=10; public static final int BOARD_WIDTH=10;
public static final int BOARD_HEIGHT =20; public static final int BOARD_HEIGHT=20;
public static final int BLOCK_SIZE=30;
private Timer loop; private Timer loop;
private Color[][] board = new Color[BOARD_WIDTH][BOARD_HEIGHT]; private Color[][] board = new Color[BOARD_WIDTH][BOARD_HEIGHT];
@ -28,9 +29,16 @@ public class Board extends JPanel
@Override @Override
protected void paintComponent(Graphics g) { protected void paintComponent(Graphics g) {
super.paintComponent(g); super.paintComponent(g);
g.setColor(Color.blue);
g.fillRect(0,0,getWidth(),getHeight()); g.fillRect(0,0,getWidth(),getHeight());
g.setColor(Color.black); g.setColor(Color.DARK_GRAY);
g.drawRect(10,10,200,200);
for(int row= 0; row< BOARD_HEIGHT;row++)
{
g.drawLine(0, BLOCK_SIZE * row, BLOCK_SIZE * BOARD_WIDTH, BLOCK_SIZE * row);
}
for(int col= 0; col< BOARD_WIDTH +1; col++)
{
g.drawLine(col * BLOCK_SIZE, 0, col * BLOCK_SIZE, BLOCK_SIZE * BOARD_HEIGHT);
}
} }
} }