Solved

Setting an icon on a java.awt.Frame

Posted on 1997-09-15
12
255 Views
Last Modified: 2008-03-17
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
Comment
Question by:Yoda
12 Comments
 

Author Comment

by:Yoda
Comment Utility
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
 

Author Comment

by:Yoda
Comment Utility
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
 
LVL 1

Expert Comment

by:quekky
Comment Utility
try other browser/VM
0
 

Author Comment

by:Yoda
Comment Utility
What do you mean?  I do not understand your comment...
0
 
LVL 1

Expert Comment

by:gnawed
Comment Utility
Show some code or elaborate on the symptoms.
0
 

Author Comment

by:Yoda
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 1

Accepted Solution

by:
vmanocha earned 50 total points
Comment Utility
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
 

Author Comment

by:Yoda
Comment Utility
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
 
LVL 1

Expert Comment

by:vmanocha
Comment Utility
i used a ".gif" file. btw, what version of JDK are you using and on what paltform ?

0
 

Author Comment

by:Yoda
Comment Utility
I am using jdk 1.1 on sun solaris
0
 

Author Comment

by:Yoda
Comment Utility
I am using jdk 1.0 on sun solaris
0
 
LVL 1

Expert Comment

by:vmanocha
Comment Utility
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

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
commonTwo  challenge 63 98
sumDigits  challenge 7 59
stringclean challenge 26 53
where is session ID cache stored 1 38
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
This video teaches viewers about errors in exception handling.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now