JPanel setBackground(Color.BLACK) does nothing

前端 未结 6 1131
不知归路
不知归路 2021-01-04 12:29

I have the folowing custom JPanel and I have aded it to my frame using Netbeans GUI builder but the background won\'t change! I can see the circle, drawing with g.fillOval()

6条回答
  •  失恋的感觉
    2021-01-04 12:31

    You need to create a new Jpanel object in the Board constructor. for example

    public Board(){
        JPanel pane = new JPanel();
        pane.setBackground(Color.ORANGE);// sets the background to orange
    } 
    

提交回复
热议问题