Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Setting an icon on a java.awt.Frame

Posted on 1997-09-15
12
Medium Priority
?
265 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
12 Comments
 

Author Comment

by:Yoda
ID: 1226957
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
ID: 1226958
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
ID: 1226959
try other browser/VM
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

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

Expert Comment

by:gnawed
ID: 1226961
Show some code or elaborate on the symptoms.
0
 

Author Comment

by:Yoda
ID: 1226962
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
 
LVL 1

Accepted Solution

by:
vmanocha earned 100 total points
ID: 1226963
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
ID: 1226964
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
ID: 1226965
i used a ".gif" file. btw, what version of JDK are you using and on what paltform ?

0
 

Author Comment

by:Yoda
ID: 1226966
I am using jdk 1.1 on sun solaris
0
 

Author Comment

by:Yoda
ID: 1226967
I am using jdk 1.0 on sun solaris
0
 
LVL 1

Expert Comment

by:vmanocha
ID: 1226968
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
In this post we will learn different types of Android Layout and some basics of an Android App.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

618 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