You have added the JPanel over the JFrame which completely blocks out the underlying container on which you have set the color.

You could do this instead:

public Gui(String title) {
   super(title);
   JPanel pane = new JPanel();
   setBounds(100, 100, 500, 500);
   setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   Container con = this.getContentPane();
   pane.setBackground(new Color(0, 0, 0));
   con.add(pane);
   setVisible(true);
}

Leave a Reply

Your email address will not be published. Required fields are marked *