• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

tray icon is not displaying

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here is how i am initialized image icon.

 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ImageIcon cannot handle .ico files. Turn it into a GIF or JPEG file instead.
 
shailesh jamloki
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@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
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How did you turn it into a GIF / JPEG file?
 
shailesh jamloki
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried the same thing still I am not able to view the icon.

Thanks
Shailesh
 
shailesh jamloki
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have edited the ico file in paint and saved it as .gif.
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
still it is not working
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried with any of the file types GIF / JPG / PNG?
 
rajesh sherla
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ???

 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java has some support for BMP, no support at all for ICO. GIF, JPG and PNG are better alternatives.
 
That feels good. Thanks. Here's a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic