title: Java: How to copy a graphics object and reuse it?
body: <p>I thought the create() function of graphics object creates a new copy of the current graphics object</p>
  
  <p>this was my code</p>
  
  <pre><code>Graphics temp;
  temp = g.create();
  temp.drawString("hello world",100,100);
  g.fillRect(200,200,50,50);
  </code></pre>
  
  <p>Now my understanding was that since temp is now a copy of the g, any change on temp would not be reflected on g. So my output should have been just a rectangle due to the fillRect function. But I am getting both the string and the rectangle on my paint output. Why is this happening and how to stop it?</p>