aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes having trouble displaying JFrame after setIconImage Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "having trouble displaying JFrame after setIconImage" Watch "having trouble displaying JFrame after setIconImage" New topic
Author

having trouble displaying JFrame after setIconImage

Nirvikalp Rao
Greenhorn

Joined: Feb 14, 2012
Posts: 27

I started learning swing, and was trying to create and display simple JFrame.
But If I am setting Icon image using
setIconImage()
,the Frame
does not show up.
Here is the code:



But if I remove 16th and 17th line,the Frame gets Displayed.
What am I missing??
Kemal Sokolovic
Bartender

Joined: Jun 19, 2010
Posts: 825
    
    5

The code works fine with me, I can't see a problem (besides the fact that you are using show() method which is deprecated).


The quieter you are, the more you are able to hear.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 9990
    
    7


Most probably your img reference is null.
Run your code from the command line and copy paste your stack trace here.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Kemal Sokolovic
Bartender

Joined: Jun 19, 2010
Posts: 825
    
    5

Even when the img is null an exception won't be thrown.
Nirvikalp Rao
Greenhorn

Joined: Feb 14, 2012
Posts: 27

Maneesh Godbole wrote:
Most probably your img reference is null.
Run your code from the command line and copy paste your stack trace here.


Sorry for late response.
It is not causing any exception,so there is no trace, as i said earlier program compiles and runs fine.
The problem is, the newly created window does not appear,as if I am using setVisible(false).
Which is not the case.
My package structure is "com.swing.mine". I have kept "icon.gif" in the directory which contains
"com".I tried putting image in "com.swing.mine" too, neither worked.
Nirvikalp Rao
Greenhorn

Joined: Feb 14, 2012
Posts: 27

Kemal Sokolovic wrote:Even when the img is null an exception won't be thrown.


Hey Kemal, I called "img.toString()" and it printed
sun.awt.image.ToolkitImage@1595f51
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4522
    
    5

Use a JPG or PNG image instead of GIF.


luck, db
There are no new questions, but there may be new answers.
Nirvikalp Rao
Greenhorn

Joined: Feb 14, 2012
Posts: 27

Darryl Burke wrote:Use a JPG or PNG image instead of GIF.

That worked,
However I am wondering,Is there no support for GIF's.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4522
    
    5

http://bugs.sun.com/view_bug.do?bug_id=6274394 --- unresolved
http://bugs.sun.com/view_bug.do?bug_id=4088017 -- won't fix

More if you search Google for bug "gif" setIconImage site:bugs.sun.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: having trouble displaying JFrame after setIconImage
 
Similar Threads
Short Question on Frame Icons
[newbie] swing...
Question about JOptionPane
about setIconImage()
How to set an icon to jnlp window?