title: I wish to take reference a JPanel I created
body: <p>Overall, I'm looking to draw a displayed JPanel onto a bufferedImage and save it to a file. But I'm having a hard time understanding how do I reference the JPanel I'm painting on.</p>
  
  <p>My class extends JPanel, and I am drawing on it but I never explicitly define a JPanel object except for I guess in my main method(when I add it to the JFrame), but this is in a different class obviuosly. How do I reference the JPanel I am implicitly drawing on in the class that extends JPanel so that  I can pass it as a parameter to :</p>
  
  <p>public static BufferedImage createImage(JComponent component)//&lt;---I want to pass my JPanel in here to create a buffered image then use ImageIO.write() to save the file.
      {
          Dimension d = component.getSize();</p>
  
  <pre><code>    if (d.width == 0 || d.height == 0)
      {
          d = component.getPreferredSize();
          component.setSize( d );
      }
  
      Rectangle region = new Rectangle(0, 0, d.width, d.height);
      return ScreenImage.createImage(component, region);
  }
  </code></pre>
  
  <p>I hope this question makes sense. I know I sound like a newbie, and it is because I am. Please help me. Thanks!</p>