This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I have a package called divelog, with a subdirectory of images, with a file diveflag.gif I am trying to load a image into a label by: jl = new JLabel("Java(TM) Technology Dive Log", new ImageIcon("images/diveflag.gif"), JLabel.CENTER);
When I run the application no image appears. Any ideas? Thanks, Dean
Joined: Sep 10, 2001
I added the full path from where the JAVA machine was running and it worked. I thought you only had to path it from where the class files exists. Does anyoine know the rules? thanks, Dean
The '/images' subdirectory must be a subdirectory of the directory where the code is located that calls for the image. For instance, if the code for divelog.java is located at 'C:\MyApps\divelog', then the '/images' sub must be located at 'C:\MyApps\divelog\images'. The CLASSPATH knows where to find it because it starts at the current directory, and your code gives it a relative path to the *.gif file, 'new ImageIcon("images/diveflag.gif"), JLabel.CENTER);', (the part in the double quotes).
(((o o)))<br />""--^--"" Entropy is Increasing...
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com