Here is something I had done a while ago... Not sure if it's any help though. It's probably far from a good solution. I don't even remember if all the libraries I've imported are all needed:
Code:import java.awt.*; import java.awt.event.*; import java.io.File; import java.io.IOException; import java.awt.Image; import javax.imageio.ImageIO; import javax.swing.JLabel; import javax.swing.ImageIcon; public class Picture extends Panel { public void createPicture(String fileName) { JLabel label = new JLabel(); try { File fImage = new File(fileName); if (fImage.exists() == false) { fImage = new File("noimage.jpg"); } Image image = ImageIO.read(fImage); label = new JLabel(new ImageIcon(image)); } catch (IOException e) { System.out.println("No image"); } this.setLayout(new BorderLayout()); this.add(label,BorderLayout.CENTER); } public Picture(String fileName) { createPicture(fileName); } }




:
Reply With Quote