Results 1 to 3 of 3
Thread: setIcon
- 05-14-2009, 09:34 PM #1
Member
- Join Date
- Apr 2009
- Posts
- 5
- Rep Power
- 0
setIcon
Hey all,
Read a couple forums posts on setting the application icon... (ie replacing the java icon)...
I'm using the code, but its just not working... I have the worldicon.png in the same package this code is running in. Does it need to be in resources or am I using the wrong call?
Thanks!
Java Code:mainScreen = new MainScreen(mainScreenDriver); mainScreen.setIconImage(new ImageIcon("worldicon.png").getImage()); mainScreen.setVisible(true);
-
Do you know for a fact that you're looking in the right place for the "worldicon.png" file? If I didn't know, I'd create the image icon in a separate step and test if it's null or not. You know of course that java is looking at the System.getProperty("user.dir") location for your file.
for instance place this line in your code to see just where Java is looking for the png file:
Also, if there's any chance that you'll want to make a JAR out of this, use resources, not files. And of course resources will start looking at a different location from the user.dir, but rather will look at the location of your class files.Java Code:System.out.println(System.getProperty("user.dir"));
- 05-15-2009, 07:12 AM #3


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks