title: How change background color of JFrame
body: <p>I can't change the background color of a JFrame, or of a JPanel inside the JFrame, this is my code:</p>
  
  <pre><code>public class MyFrame extends JFrame {
  
      public MyFrame(){
          setSize(600,600);
          setResizable(false);
          panel = new MyPanel();
          panel.setBackground(Color.BLACK);
          //getContentPane().setBackground(Color.BLACK); doesn't work
          getContentPane().add(panel);
          addWindowListener(new WindowAdapter(){
              public void windowClosing(WindowEvent ev){
                  System.exit(-1);
              }
              public void windowClosed(WindowEvent ev){
                  System.exit(-1);
              }
          });
      }
  
   public void paint(Graphics g){
          super.paint(g);
          g.clearRect(0,0,600,600);
          synchronized (this){
              if (positions!=null){
                  for (int i=0; i&lt;positions.length; i++){
                      P2d p = positions[i];
                      //int x0 = (int)(180+p.x*180);
                      //int y0 = (int)(180-p.y*180);
                      g.drawOval((int)p.x,(int)p.y,5,5);
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>i have tried in several ways, but I can not change the color, it's always white, how i can do?</p>