title: java+Swing: efficient overlay of rectangle or other "sprite"
body: <p>I'm not quite sure how to phrase this, so bear with me.</p>
  
  <p>I have two <code>JPanel</code>s in a container <code>JPanel</code> with an <code>OverlayLayout</code>. Both <code>JPanel</code>s in the container override <a href="http://download.oracle.com/javase/6/docs/api/javax/swing/JComponent.html#paint%28java.awt.Graphics%29" rel="nofollow"><code>paint(Graphics)</code></a>.</p>
  
  <p>The bottom <code>JPanel</code> is opaque and draws some fairly complicated graphics, so it takes a "long" time (10s or 100s of milliseconds) to render.</p>
  
  <p>The top <code>JPanel</code> is transparent and just draws a rectangle or line or simple shape based on mouse input, so it's really quick.</p>
  
  <p><strong>Is there a way to set things up so when I change the simple shape in the upper panel, it doesn't redraw the bottom panel?</strong> (e.g. it somehow caches the bottom panel)</p>
  
  <p>I'm vaguely familiar w/ concepts like bitblt, double-buffering, and XOR-drawing but not really sure what to apply here.</p>