title: Showing an image using JPanel
body: <p>I have written my own ImagePanel using one of previous topics here:</p>
  
  <pre><code>import java.awt.Graphics;
  import java.awt.image.BufferedImage;
  import javax.swing.JPanel;
  
  public class ImagePanel extends JPanel{
  
      private BufferedImage image = null;
  
      public ImagePanel(BufferedImage im) {
         image = im;
      }
  
      @Override
      public void paintComponent(Graphics g) {
          super.paintComponent(g);
          g.drawImage(image, 0, 0, null);            
      }
  }
  </code></pre>
  
  <p>And then I thought it would be nice to add this panel on the normal JPanel(it would be easier to put it on the frame using this all NetBeans stuff). So I added one, NetBeans generated me some code:
  <code>private javax.swing.JPanel pnlImagePanel;</code>
  And here it comes the moment when I would like to show image, so:</p>
  
  <pre><code>File selectedFile = new File(path);
  try {
         image = ImageIO.read(selectedFile);
  } catch(IOException ex) {
         throw new RuntimeException(ex);
  }
  ImagePanel imPanel = new ImagePanel(image);
  this.pnlImagePanel = imPanel;
  this.pnlImagePanel.repaint();
  </code></pre>
  
  <p>Problem is obvious - I got no result. Shouldn't it work? I've overriden the method paintComponent, so polymorphism should fire. Or is something missing to me?</p>