Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to display an image for window icon in Swings  RSS feed

 
Hiren Pathak
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I want to add an image for the Window Icon in Swings. I am trying to use
Toolkit toolkit = Toolkit.getDefaultToolkit();
Image image1 = toolkit.getImage("favicon.ico");
frame.setIconImage(image1);
but this is not working. can anyone help me.? :roll:
 
Bill White
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ImageIcon titleBarIcon =
new ImageIcon("myTitleBarImage.jpg");
Image i = titleBarIcon.getImage();
this.setIconImage(i);
 
Hiren Pathak
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanks. Do I must have to use .jpg or can I use .ico files too..? because somehow I tried that code with .ico file and its not working.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The basic JDK can't load .ico files... they are only used on the windows platform. Convert your .ico file to a GIF, JPEG, or PNG...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!