Image problem...

I was tring this code to change frame's icon but it didnt work. And I tried the same thing to assign an image to my tray icon too:

window.setIconImage(Toolkit.getDefaultToolkit().getImage("image.png"));

But it doesnt work. Nothing happens with this code. I have tried to write the name of image's path and name, only name (image was in .../src/images/ directory). I was sure that I have written the path and the name correctly. I am using Ubuntu.

Thanks for any help...

[521 byte] By [Genomsarena] at [2007-11-27 10:37:40]
# 1

The code is okay, it must be your image location that is the problem.

_helloWorld_a at 2007-7-28 18:49:44 > top of Java-index,Java Essentials,Java Programming...
# 2

What do you mean with that? I have written it with full path too... But it didnt work...

Genomsarena at 2007-7-28 18:49:44 > top of Java-index,Java Essentials,Java Programming...
# 3

Try putting the image in another location, say root "/image.png" and then try the with this path. The code you posted looks okay, another option is to use a debugger with a breakpoint placed before your image loads.

_helloWorld_a at 2007-7-28 18:49:44 > top of Java-index,Java Essentials,Java Programming...
# 4

Thanks Im tring...

Message was edited by:

Genomsaren

Genomsarena at 2007-7-28 18:49:44 > top of Java-index,Java Essentials,Java Programming...
# 5

Try the this code too:

window.setIconImage(new ImageIcon(getClass().getResource("image.png").getImage());

Path u have specified implies that the java or .class file u are working on is in the same folder as the image.png. if not, then please specify the path properly.

Let us know what happens next.

bartropa at 2007-7-28 18:49:44 > top of Java-index,Java Essentials,Java Programming...
# 6

Thanks. I noticed that the image files should be .gif.

Genomsarena at 2007-7-28 18:49:44 > top of Java-index,Java Essentials,Java Programming...