Set background color in Java on a JPanel doesn't work

后端 未结 3 700
我在风中等你
我在风中等你 2020-12-21 02:42

I am working on a \"paint-like\" application (a little drawing software) to familiarize with Java 2D components. Here is my problem: I have a JFrame whose ContentPane is an

3条回答
  •  庸人自扰
    2020-12-21 03:07

    Some components' background is switched off by default. The background color is only applied to opaque widgets. Call the following method for all components in your widget hierarchie that should paint its background:

    c.setOpaque(true);
    

提交回复
热议问题