I have a JPanel to which I\'d like to add JPEG and PNG images that I generate on the fly.
All the examples I\'ve seen so far in the Swing Tutorials, specially in the
If you are using JPanels, then are probably working with Swing. Try this:
BufferedImage myPicture = ImageIO.read(new File("path-to-file"));
JLabel picLabel = new JLabel(new ImageIcon(myPicture));
add(picLabel);
The image is now a swing component. It becomes subject to layout conditions like any other component.