1 File imageFile=new File("C:\\garden.jpg");
2 try {
3 FileInputStream fis=new FileInputStream(imageFile);
4
5 BufferedImage buffImg=ImageIO.read(fis);
6 Image img=Toolkit.getDefaultToolkit().createImage(buffImg.getSource());
7 ImageIcon imgico=new ImageIcon(img);
8 jLabel1.setIcon(imgico);
9
10 } catch (Exception e) {
11 System.out.println("Error : " + e.getMessage());
12 }
JLabel only supports ImageIcon type.
0 comments:
Post a Comment