How to change the background color on a Java panel?

后端 未结 4 825

Right now, the background I get is a grey. I want to change it to black. I tried doing something like setBackground(color.BLACK); but it didnt work. Any suggestions?

4条回答
  •  失恋的感觉
    2021-02-07 16:49

    I think what he is trying to say is to use the getContentPane().setBackground(Color.the_Color_you_want_here)

    but if u want to set the color to any other then the JFrame, you use the object.setBackground(Color.the_Color_you_want_here)

    Eg:

    jPanel.setbackground(Color.BLUE)
    

提交回复
热议问题