title: Graphics - How do I use the method create(int x, int y, int width, int height) and translate(int x, int y)?
body: <p>I was trying to do my computer science homework but I am stuck as I was trying to use the following methods. </p>
  
  <ol>
  <li><p><code>public Graphics create(int x,int y,int width,int height)</code></p>
  
  <p>That Creates a new Graphics object based on this Graphics object, but with a new translation and clip area.</p>
  
  <p>Parameters:</p>
  
  <ul>
  <li>x - the x coordinate.</li>
  <li>y - the y coordinate.</li>
  <li>width - the width of the clipping rectangle.</li>
  <li>height - the height of the clipping rectangle.<br>
  &nbsp;</li>
  </ul></li>
  <li><p><code>public abstract void translate(int x,int y)</code></p>
  
  <p>That Translates the origin of the graphics context to the point (x, y) in the current coordinate system. </p></li>
  </ol>
  
  <p>Can anyone explain and give examples of how to use them?</p>
  
  <p>i was trying to do this..</p>
  
  <pre><code>public Graphics drawPlayer1()
  {
      myPencil.up();
      myPencil.move(-620,300);
      myPencil.down();
      myPencil.fillCircle(20);
      myPencil.up();
      myPencil.move(-590,300);
      myPencil.drawString("Player1: " + player1);
      p1.create(-620,300,40,40);
      return p1;
  }//end drawPlayer1
  </code></pre>
  
  <p>and it threw me a nullPointerException when it comes to p1.create(-620,300,40,40);</p>