Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / June 2005

Tip: Looking for answers? Try searching our database.

Help!! Can't display ImageIcon!

Thread view: 
brightoceanlight@hotmail.com - 22 Jun 2005 15:32 GMT
Hi,

I have been through other posts regarding this problem.  But their
solutions don't fix my problem.

I have tried different variations, but the basic is :

    ImageIcon lIcon = new ImageIcon("pic.bmp");
    JLabel jl = new JLabel(lIcon);
    addComponent(dpanel, jl, 0 ,0, 100, 100);

But nothing shows up.  I also tried :

    java.net.URL thePic = this.getClass().getResource("pic.bmp");
    System.out.println("Pic URL is: " + thePic);
    String dir = System.getProperty("user.dir");
    System.out.println("user dir : " + dir);
    ImageIcon lIcon = new ImageIcon(thePic);
    if(leafIcon.getImageLoadStatus() ==  MediaTracker.COMPLETE) {
      JLabel jl = new JLabel(lIcon);
      addComponent(dpanel, jl, 0 ,0, 100, 100);
    }

Also doesn't work.  

Any help greatly appreciated!!

Thanks,

Gil
Andrew Thompson - 22 Jun 2005 15:51 GMT
(loading image..)

> I have tried different variations, but the basic is :
>
[quoted text clipped - 3 lines]
>
> But nothing shows up.  

I suggest
- (for the moment) you stick to *one* version.
- Show a *complete* example that shows what you are attempting to do.
<http://www.physci.org/codes/sscce.jsp>
..and..

>..I also tried :
..
> Also doesn't work.  

Be a lot more explicit about what "doesn't work" and *why*.
<http://www.physci.org/codes/javafaq.jsp#exact>

All I can determine from "doesn't work" is "might be lazy".  [ ;-) ]

Signature

Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane

brightoceanlight@hotmail.com - 23 Jun 2005 08:27 GMT
Thank you everyone for the posts!

I don't know why I would have ever thought .bmp files would be
supported in Java.  I plead temporary insanity.

Choosy mothers prefer Gif.

Thanks,

Gil
Andrew Thompson - 23 Jun 2005 08:54 GMT
> I don't know why I would have ever thought .bmp files would be
> supported in Java.  

Ehh.. Yeh - I missed that bit.  

Fortunately Thomas noticed it.

>..I plead temporary insanity.

;-)

> Choosy mothers prefer Gif.

Actually, ..there *was* an entire movement of people who
hated(d) GIF's as well. The patent was owned by ..compuserve(?)
and the legal hassles of using GIF's had folks making comments
such as 'burn all GIFs'.

The patent on GIF's ran out recently, so I am not sure what
the current position is.

[ Personally, I prefer .PNG.  ;-) ]

Signature

Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane

Thomas Fritsch - 22 Jun 2005 19:39 GMT
brightoceanlight@hotmail.com schrieb:
> Hi,
Hi !

> I have been through other posts regarding this problem.  But their
> solutions don't fix my problem.
>
> I have tried different variations, but the basic is :
>
>      ImageIcon lIcon = new ImageIcon("pic.bmp");
Are you sure, that your Java supports decoding BMP images?
I am pretty sure that Sun's Java supports GIF, JPEG, PNG (and maybe
more), but not BMP. Therefore I suggest, you try with a GIF image first,
to see if that doesn't work, too.

>      JLabel jl = new JLabel(lIcon);
>      addComponent(dpanel, jl, 0 ,0, 100, 100);
[quoted text clipped - 18 lines]
>
> Gil

Signature

"Thomas:Fritsch$ops:de".replace(':','.').replace('$','@')



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.