this.setBackground() doesn't seem to affect the background of the mainframe Jframe without removing setLayout(null) I set to it. How do I resolve this?
Here's my code:
public class MainFrame extends JFrame {
public final static int SQUARE_UNIT = 35;
int frameHeight = SQUARE_UNIT* 22;
public final int frameWidth = SQUARE_UNIT *22;
Color frameColor = new Color(0x20252B);
MainFrame() {
this.setTitle("Tetris");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setResizable(false);
this.setPreferredSize(new Dimension(frameWidth,frameHeight));
this.setLayout(null);
this.setBackground(frameColor);
}
public static void main(String[] args) {
MainFrame gameFrame = new MainFrame();
Board tetrisBoard = new Board(MainFrame.SQUARE_UNIT,MainFrame.SQUARE_UNIT);
gameFrame.add(tetrisBoard);
gameFrame.setVisible(true);
gameFrame.pack();
}
}