Close
jGuru Forums
Posted By: Sowjanya_Raghu Posted On: Monday, November 5, 2001 05:30 PM
I am having trouble trying to display an image on a JLabel. The code I have been trying is as follows: ImageIcon icon = new ImageIcon ("airplane4.gif"); System.out.println("Size of the Image = " + icon.getIconHeight() + "..." + icon.getIconWidth()); if (icon == null) { System.out.println("Icon not loaded"); } else { System.out.println("Icon loaded = " + icon); } JLabel imageLabel = new JLabel(icon); When I try to display the loaded images's width and height, I get -1 as the reply. Any idea as to where I am going wrong will be much appreciated. Thanks,
Re: How do I display an image on a JLabel
Posted By: mohammad_afzal Posted On: Wednesday, November 7, 2001 01:55 AM