title: Painting on JFrame without extending
body: <p>My application is not JFrame-oriented, it just uses one for output. I just need to be able to tell it to draw a rectangle here, clear the screen now, a few hundred times. To do this, I wrote the following code in my main, which, by my understanding, should clear the entire JFrame to a nice blue background color.</p>
  
  <pre><code>JFrame frame = new JFrame("Maze Master Premium Super-Deluxe V199.39");
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  int resolution = 20;
  int frameWidth = horiz * resolution;
  int frameHeight = vert * resolution;
  frame.setMinimumSize(new Dimension(frameWidth, frameHeight));
  frame.setSize(frameWidth, frameHeight);
  frame.pack();
  frame.setVisible(true);
  frame.toFront();
  
  Graphics g = frame.getGraphics();
  g.setPaintMode();
  g.setColor(Color.BLUE);
  //Clear background
  g.fillRect(0, 0, frameWidth, frameHeight);
  frame.update(g);
  </code></pre>
  
  <p>But when I run this, the JFrame displays with its default light-gray background color. Do I have to have my class extend JFrame, or is it sufficient to use frame.update(g) and I'm just getting something else wrong?</p>