title: How to add an image to a JPanel?
body: <p>I have a <a href="http://download.oracle.com/javase/1.4.2/docs/api/javax/swing/JPanel.html" rel="noreferrer">JPanel</a> to which I'd like to add JPEG and PNG images that I generate on the fly.</p>
  
  <p>All the examples I've seen so far in the <a href="http://java.sun.com/docs/books/tutorial/uiswing/" rel="noreferrer">Swing Tutorials</a>, specially in the <a href="http://java.sun.com/docs/books/tutorial/uiswing/examples/components/" rel="noreferrer">Swing examples</a> use <code>ImageIcon</code>s.</p>
  
  <p>I'm generating these images as byte arrays, and they are usually larger than the common icon they use in the examples, at 640x480.</p>
  
  <ol>
  <li>Is there any (performance or other) problem in using the ImageIcon class to display an image that size in a JPanel?</li>
  <li>What's the <em>usual</em> way of doing it?</li>
  <li>How to add an image to a JPanel without using the ImageIcon class?</li>
  </ol>
  
  <p><strong>Edit</strong>: A more careful examination of the tutorials and the API shows that you cannot add an ImageIcon directly to a JPanel. Instead, they achieve the same effect by setting the image as an icon of a JLabel. This just doesn't feel right...</p>