• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 271
  • Last Modified:

Setting an icon on a java.awt.Frame

I am trying to set the icon for a java.awt.Frame which I am using.  Has anyone done this before and if so, could you provide me with some tips/help.  Thanks.
0
Yoda
Asked:
Yoda
1 Solution
 
YodaAuthor Commented:
I have been trying to use the setIconImage(image) method with the java.awt.Frame class, but I have not been successful at getting it to work.  Does anyone know how to get this to work correctly?
0
 
YodaAuthor Commented:
I have been trying to use the setIconImage(image) method with the java.awt.Frame class, but I have not been successful at getting it to work.  Has anyone been successful at getting this to work and if so, could you show me what you did?
0
 
quekkyCommented:
try other browser/VM
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
YodaAuthor Commented:
What do you mean?  I do not understand your comment...
0
 
gnawedCommented:
Show some code or elaborate on the symptoms.
0
 
YodaAuthor Commented:
a = applet;
            theNode = node;
            try
            {
                image = a.getImage(new URL("http://bdssun.bdsinc.com/TreeView.ico"));
                System.out.println("Got image for icon...");
            }
            catch (MalformedURLException e)
            {
            }
            this.setIconImage(image);

This is the code I have in my java.awt.Frame:

I use the setIconImage(image) method and it does not contain the image when I run the frame in my browser.  Everything compiles ok, and the icon is on my server in the correct directory.  It just does not seem to work.
0
 
vmanochaCommented:
The following program when run using JDK 1.1.3 works and sets the image as specified in the <imagename>. the <imagename> can either be a string pointing to the full path+filename of the image or it can be a URL.

//======
import java.awt.*;

public class J2
{
      public static void main(String args[])
      {
            Frame frm = new Frame("J2");

            try{
                  frm.setIconImage(frm.getToolkit().getImage(<imagename>));
            }
            catch(Exception e)
            {
                  e.printStackTrace();
            }

            frm.reshape(10, 10, 100, 100);
            frm.show();

      }
}
//======
0
 
YodaAuthor Commented:
I tried using that exact same code and when I open up the frame in the browser it still shows the default java icon.  Does it accept .ico or .gif or .jpg?
0
 
vmanochaCommented:
i used a ".gif" file. btw, what version of JDK are you using and on what paltform ?

0
 
YodaAuthor Commented:
I am using jdk 1.1 on sun solaris
0
 
YodaAuthor Commented:
I am using jdk 1.0 on sun solaris
0
 
vmanochaCommented:
you are right. it does not seem to work from within a browser. i tried it with Netscape 3.x and MS IE 3.x on Windows NT 4.0. But it does work if you use it in an application using JDK 1.1.3.
Probably it is another one of those browser issues or a bug in JDK 1.0.2 implementation of Java !!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now