要是单纯的设置一个窗口的背景颜色,背景颜色是    this.getContentPane().setBackground(Color.GREEN); 但是我在这个窗口里画一个红色的圆,背景颜色却是   this.setBackground(Color.GREEN);
我想不明白?

解决方案 »

  1.   

    this.getContentPane()返回了红色圆圈所在的基本panel
      

  2.   


    public void paint(Graphics g){
    g.setColor(Color.RED);
    g.fillOval(x, y, width, height);
    }
      

  3.   

    不好意思,没表达清楚。
    我是想一个800*600的窗口,背景设置成蓝色,上面画一个红色的圆。如果不画那个圆,背景颜色设置是  this.getContentPane().setBackground(Color.GREEN);但是如果画圆,窗口的背景颜色设置用this.getContentPane().setBackground(Color.GREEN);却不行。是为什么??