| Author |
tray icon is not displaying
|
shailesh jamloki
Ranch Hand
Joined: Oct 28, 2004
Posts: 38
|
|
I have a small program, where i add a tray icon (with ico image) to the system tray and I am adding some menu-item to it etc. I can see the space in the system tray. I can see all the menu-items in it. when i click/right click. But the icon image is not showing. Earlier i assumed that, there is a possiblity that the ico image size is big and hence it is not showing. So i replaced it with small .ico image. but still it is not showing. can you please help me in the same? Thanks for the help.
|
 |
shailesh jamloki
Ranch Hand
Joined: Oct 28, 2004
Posts: 38
|
|
here is how i am initialized image icon.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19232
|
|
|
ImageIcon cannot handle .ico files. Turn it into a GIF or JPEG file instead.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
shailesh jamloki
Ranch Hand
Joined: Oct 28, 2004
Posts: 38
|
|
@above Thanks for the suggestion. I am still not able to see the image icon in the system tray. any more suggestions? Thanks Shailesh
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19232
|
|
|
How did you turn it into a GIF / JPEG file?
|
 |
shailesh jamloki
Ranch Hand
Joined: Oct 28, 2004
Posts: 38
|
|
I hope I am not doing it wroingly.But I have just changed the extension of the file to .gif and .jpeg. If it is not the correct way of doing it. Can you please tell me. How can I do it?
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19232
|
|
If you rename your file it will still be an ICO file. You will need to open it in a graphics editor (Photoshop, Paintshop Pro, GIMP, Paint.NET, etc), then save it as JPG or even better GIF (since GIF can preserve transparancy).
|
 |
shailesh jamloki
Ranch Hand
Joined: Oct 28, 2004
Posts: 38
|
|
I tried the same thing still I am not able to view the icon. Thanks Shailesh
|
 |
shailesh jamloki
Ranch Hand
Joined: Oct 28, 2004
Posts: 38
|
|
|
I have edited the ico file in paint and saved it as .gif.
|
 |
Gregg Bolinger
Ranch Hand
Joined: Jul 11, 2001
Posts: 15230
|
|
Originally posted by shailesh jamloki: I have edited the ico file in paint and saved it as .gif.
And it is still not working or it is now working?
|
 |
shailesh jamloki
Ranch Hand
Joined: Oct 28, 2004
Posts: 38
|
|
|
still it is not working
|
 |
Gregg Bolinger
Ranch Hand
Joined: Jul 11, 2001
Posts: 15230
|
|
Originally posted by shailesh jamloki: still it is not working
Can you link to your image and I'll have a go at using it to make sure the image is ok?
|
 |
shailesh jamloki
Ranch Hand
Joined: Oct 28, 2004
Posts: 38
|
|
yeah sure.. I am using this gif file. Can you please try the same, thanks Shailesh [ September 29, 2008: Message edited by: shailesh jamloki ]
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19232
|
|
I did, and it worked fine for me: Although I had to rename the picture from ant1.jpg to ant1.gif after I downloaded it, and only part of it was shown. The latter could be remedied with the following line: So the file itself is fine. Your next question: does the file exist at the location you provided? What happens if you add the following line:
|
 |
shailesh jamloki
Ranch Hand
Joined: Oct 28, 2004
Posts: 38
|
|
I have added the line ti.setImageAutoSize(true); and I am also printing System.out.println("FILE EXISTANCE CHECK------>"+new File("c:\\ant1.gif").exists()); output :- FILE EXISTANCE CHECK------>true but still the icon is not visible. but the blank -space is visible in the system tray.
|
 |
shailesh jamloki
Ranch Hand
Joined: Oct 28, 2004
Posts: 38
|
|
Is it dependent on OS we have used. or the JRE version ? I am using sun's 1.6 and windows xp.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19232
|
|
That can't be the problem, because so have I. Just to make sure, you are positive you have changed the file extension in the code creating the image as well? That doesn't still say .ico, does it?
|
 |
rajesh sherla
Greenhorn
Joined: Apr 04, 2010
Posts: 11
|
|
Hi,
Myself also facing the same issue i.e. icon image is not getting displayed on System tray.
I have written java code as follows:
return (new ImageIcon("flower.bmp","tray icon")).getImage()
and
return (Toolkit.getDefaultToolkit().getImage("flower.bmp"));
Also i tried with below code:
URL imageURL11 = ClassLoader.getSystemResource("flower.bmp");
Image image = Toolkit.getDefaultToolkit().getImage(imageURL11);
return image;
But none of them showing me icon on System tray.
Rest of the program is working fine.
|
 |
Darryl Burke
Bartender
Joined: May 03, 2008
Posts: 4203
|
|
Have you tried with any of the file types GIF / JPG / PNG?
|
luck, db
There are no new questions, but there may be new answers.
|
 |
rajesh sherla
Greenhorn
Joined: Apr 04, 2010
Posts: 11
|
|
yes, i changed my image file type from bmp to gif, then it worked.
Also jpg file type is also working fine.
But image file with extension "ico" (icon type) and "bmp" (bitmap type) are not working.
Is there any specific reason for this ???
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16487
|
|
rajesh sherla wrote:yes, i changed my image file type from bmp to gif, then it worked.
Also jpg file type is also working fine.
But image file with extension "ico" (icon type) and "bmp" (bitmap type) are not working.
Is there any specific reason for this ???
Well, yes, it's because the code was written to handle GIF and JPG files but not to handle ICO and BMP files.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19232
|
|
|
Java has some support for BMP, no support at all for ICO. GIF, JPG and PNG are better alternatives.
|
 |
 |
|
|
subject: tray icon is not displaying
|
|
|