Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

icon on JFrame

 
Cindy Lyman
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Does anybody know how to customize the icon on JFrame?
The default icon is the Java cup on the upper left corner of the
JFrame. I want to change it into my own icon.
Any suggestion would be appreciated.
Cindy
 
Shishir Parikh
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Use the setImageIcon(Image img) of java.awt.Frame to set your icon in the titlebar.
Eg:
If u r using a Properties file, u may do something like this
setIconImage(Toolkit.getDefaultToolkit().createImage(properties.getProperty("ICON_IMAGEFILE")));
 
Cindy Lyman
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. It works and now I have another question.
Do you know if I use imagefile .ico instead of .gif or .jpg?
is anyway to accomplish this?

Thank you again,
Cindy
 
Cindy Lyman
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. It works and now I have another question.
Do you know if I use imagefile .ico instead of .gif or .jpg?
is anyway to accomplish this?

Thank you again,
Cindy
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Normally java can only read a .gif or a .jpg image. For some reason, lots of people have been asking about reading .ico files recently, and I finally found a way to read .ico files... Sun has a image I/O library called JIMI ) for managing images.

-Nate
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic