-
setIconImage() problem
I'm sure someone has probably ask this question before, but please bear with
me as I post it again. I am having problems getting an image to display as
the application's icon. I am using the following code to set the image.
setIconImage(Toolkit.getDefaultToolkit().getImage("app_icon.gif"));
I've also tried...
setIconImage((new ImageIcon("app_icon.gif")).getImage());
Both should work, but the icon doesn't show up. The default icon is no
longer there so I at least know something is happening. I am running Win
2000 Professional SP2 and the image is a non-transparent gif 16x16. I would
appreciate any suggestions.
Thanks,
Jeff
-
Re: setIconImage() problem
Probably your GIF file isn't in the current directory, or the current
directory isn't what you think it is. Here's the code I use to do that; it
uses a method that searches the classpath for my icon:
frame.setIconImage(frame.getToolkit().getImage(getClass().getResource("/Bird
icon.jpeg")));
PC2
"Jeff" <jeffdeanda@earthlink.net> wrote in message
news:3b49d0f6$1@news.devx.com...
> I'm sure someone has probably ask this question before, but please bear
with
> me as I post it again. I am having problems getting an image to display as
> the application's icon. I am using the following code to set the image.
>
> setIconImage(Toolkit.getDefaultToolkit().getImage("app_icon.gif"));
>
> I've also tried...
>
> setIconImage((new ImageIcon("app_icon.gif")).getImage());
>
> Both should work, but the icon doesn't show up. The default icon is no
> longer there so I at least know something is happening. I am running Win
> 2000 Professional SP2 and the image is a non-transparent gif 16x16. I
would
> appreciate any suggestions.
>
> Thanks,
> Jeff
>
>
>
-
Re: setIconImage() problem
Hi Paul,
Thanks for the advice. I figured out what it was. Here's my code now:
setIconImage(new
ImageIcon(getClass().getResource("/app_icon.gif")).getImage());
And what I was using before:
setIconImage((new ImageIcon("app_icon.gif")).getImage());
It seems that by excluding "getClass().getResource("/app_icon.gif")" from
the call it wasn't able to retrieve the graphic.
Thanks,
Jeff
"Paul Clapham" <pclapham@core-mark.com> wrote in message
news:3b4b146a$1@news.devx.com...
> Probably your GIF file isn't in the current directory, or the current
> directory isn't what you think it is. Here's the code I use to do that;
it
> uses a method that searches the classpath for my icon:
>
>
>
frame.setIconImage(frame.getToolkit().getImage(getClass().getResource("/Bird
> icon.jpeg")));
>
> PC2
>
> "Jeff" <jeffdeanda@earthlink.net> wrote in message
> news:3b49d0f6$1@news.devx.com...
> > I'm sure someone has probably ask this question before, but please bear
> with
> > me as I post it again. I am having problems getting an image to display
as
> > the application's icon. I am using the following code to set the image.
> >
> > setIconImage(Toolkit.getDefaultToolkit().getImage("app_icon.gif"));
> >
> > I've also tried...
> >
> > setIconImage((new ImageIcon("app_icon.gif")).getImage());
> >
> > Both should work, but the icon doesn't show up. The default icon is no
> > longer there so I at least know something is happening. I am running Win
> > 2000 Professional SP2 and the image is a non-transparent gif 16x16. I
> would
> > appreciate any suggestions.
> >
> > Thanks,
> > Jeff
> >
> >
> >
>
>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks