title: about adding a BufferedImage to the JPanel
body: <p>I'm still learning about the Java Swing toolkit and how it works. I'm researching different ways on how to add an image to my JFrame (via the JPanel) and found this tutorial (<a href="http://download.oracle.com/javase/tutorial/2d/images/loadimage.html" rel="nofollow">HERE</a>). My question has to do with the way I setup my source code:</p>
  
  <pre><code>public class GraphicsPracticeDrawing extends JPanel{
  
      private BufferedImage img;
  
      public GraphicsPracticeDrawing() {
              this.setBackground(Color.BLACK);
              //Initialize(); //Program runs with no error/warning, but nothing appears in frame
      }
  
      //method initialized the BufferedImage
      public void Initialize() {
              try {
                      img = ImageIO.read(new File("images/star.jpg"));
              } catch (IOException e) {
                      e.printStackTrace();
              }
      }
  
      public void paint(Graphics g) {
              super.paint(g);
  
              Initialize(); //initialize the BufferedImage
  
              g.drawImage(img, 25, 25, null);
      }
  </code></pre>
  
  <p>}</p>
  
  <p>If I was to take away the Initialize method and put the try/catch (to initialize my image) inside my constructor, my code compiles and runs but I end up with a blank window. If I put the try/catch in paint, like it's shown in my source my program runs perfectly fine, images loads, black background, and everything.</p>
  
  <p><strong>TLDR;</strong> Image1 is what happens when I initialize in the constructor, Image 2 is what happens when it runs fine and I initialize in my paint method. <strong>(<a href="http://imgur.com/a/tAoZ9" rel="nofollow">Take a Look</a>)</strong></p>
  
  <p>Why can't I initialize my image in my constructor?</p>