SV: JLabels and gifs

"Christian Hessenbruch" <[email protected]>
Newsgroups gmane.comp.java.netbeans.user-interface
Message-ID <AE8BABF1A8D7C64F8CE8F6405A6B6CB133F6E7@guidom>
Remember '/' before filename

Also remember to build the project or the gif's may not be part of the
.jar thus not accessible.


-----Oprindelig meddelelse-----
Fra: Locascio, Jim [mailto:[email protected]] 
Sendt: 22. november 2006 04:08
Til: [email protected]
Emne: [nbui] JLabels and gifs

Hello,
I am building a java app which includes JLabels with text and a gif file
as the icon.  The text for the JLabel always displays.  However, the gif
images only display when I create the ImageIcon with the full directory
path to the gif files.  If I try to use a relative path the gif files
are not found.  I have tried placing the gif files in my classes
directory and executing
blankIcon = new ImageIcon("e.gif");
but the file is not found.  I have tried numerous other relative paths,
none work.
   
The relevant code is as follows:
******************************************
//Class vars
private final String blankCard = "e.gif";
private ImageIcon blankIcon;
//the different directory options I have tried. Only the full
//path works.
// private final String directory = "C:\\Documents ...\\"
private final String directory = "cards\\";
//private final String directory = "";

//In my Frame code
blankIcon = new ImageIcon(directory + blankCard);
blankLabel = new JLabel("Blank Card Text", blankIcon,JLabel.CENTER);

//Then add the blankLabel to a JPanel.
The text displays, but the icon image does not.
Any suggestions would be greatly appreciated.
 
 
Thank you,
Jim Locascio
Math Teacher
Vernon Hills High School
[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.