Board in gui eingepackt

This commit is contained in:
Ewen Kerbs 2021-11-11 14:44:57 +01:00
parent 3b7d5d8dad
commit ce68473591

View File

@ -9,7 +9,8 @@ import javax.swing.Timer;
public class Board extends JPanel
{
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 Color[][] board = new Color[BOARD_WIDTH][BOARD_HEIGHT];
@ -28,9 +29,16 @@ public class Board extends JPanel
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(Color.blue);
g.fillRect(0,0,getWidth(),getHeight());
g.setColor(Color.black);
g.drawRect(10,10,200,200);
g.setColor(Color.DARK_GRAY);
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);
}
}
}