?
Solved

java.awt.Frame and setIconImage(Image image)

Posted on 1998-01-15
6
Medium Priority
?
926 Views
Last Modified: 2008-02-01
I want to set the icon of my Frame object to be an specific .ico file which I have on my local file system.  I know that java.awt.Frame has setIconImage, but I am having a problem creating an Image object.  How do I create an Image object to be my icon?

The name of the icon is rocket.ico, and it is located in C:\Myjava.
0
Comment
Question by:bjg
  • 3
  • 3
6 Comments
 

Accepted Solution

by:
rjg2000 earned 200 total points
ID: 1232227
To the best of my knowledge

Java cannot read .ico files.
Convert is to a gif using Paint Shop Pro
and then load that image in the normal way.
0
 

Author Comment

by:bjg
ID: 1232228
What is the normal way to load an .gif image?
0
 

Expert Comment

by:rjg2000
ID: 1232229
Applets
-------
      Image i = this.getImage(this.getDocumentBase(),"image.gif");

Applications
------------
Toolkit tk = Toolkit.getDefaultToolkit();
Image i = tk.loadImage(filename);

you may want to use a MediaTracker to check the image has
finished loaded before calling setIconImage


0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:bjg
ID: 1232230
It's getImage, not loadImage, but thanks, it worked.
0
 

Author Comment

by:bjg
ID: 1232231
By the way, how does PaintShopPro convert an icon to a gif?  I tried it and PaintShopPro says that .ico is unrecognized file type.
0
 

Expert Comment

by:rjg2000
ID: 1232232
Umm,  Ok, got it wrong there, I belive that paintbrush can
handle .ico files.  You will then have to save it as a bitmap
(or just copy it into the clipboard) and the place it it PSP to
save it as a .gif (As paintbush does not support gifs!)

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses
Course of the Month16 days, 8 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question