• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

having trouble displaying JFrame after setIconImage

 
Greenhorn
Posts: 27
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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??
 
Bartender
Posts: 825
5
Python Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The code works fine with me, I can't see a problem (besides the fact that you are using show() method which is deprecated).
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Most probably your img reference is null.
Run your code from the command line and copy paste your stack trace here.
 
Kemal Sokolovic
Bartender
Posts: 825
5
Python Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Even when the img is null an exception won't be thrown.
 
Nirvikalp Rao
Greenhorn
Posts: 27
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 27
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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

 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use a JPG or PNG image instead of GIF.
 
Nirvikalp Rao
Greenhorn
Posts: 27
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic