I wanted to show a .tif image on a JPanel but have not been successful..
tried using ImageIcon - no success.
I am sure it is easy - need some pointers please
Scott
> I wanted to show a .tif image on a JPanel but have not been successful..
> tried using ImageIcon -
What have you tried Scott, got an example?
<http://www.physci.org/codes/sscce.jsp>
>...no success.
Please tell us any stacktrace or
exact results you are getting..
<http://www.physci.org/codes/javafaq.jsp#exact>
> I am sure it is easy - need some pointers please
It is fairly easy, though there are a few
'gotchas'. Need some more info. to give you
more specific advice.

Signature
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
Scott Collier - 16 May 2004 16:38 GMT
This is what I have tried:
...
ImageIcon img=new ImageIcon("D:\\mypic.tif");
JLabel jl=new JLabel(img);
myPanel.add(jl);
...
The code works for "D:\\mypic.gif"
> > I wanted to show a .tif image on a JPanel but have not been successful..
> > tried using ImageIcon -
[quoted text clipped - 13 lines]
> 'gotchas'. Need some more info. to give you
> more specific advice.
Andrew Thompson - 16 May 2004 16:51 GMT
> "Andrew Thompson" <SeeMySites@www.invalid> wrote in message
>>
>>> I wanted to show a .tif image on a JPanel but have not been successful..
>>> tried using ImageIcon -
Ahh.. wait, think I have (now) spotted the problem.
The JavaDocs for ImageIcon (links here..)
<http://www.physci.org/api.jsp?class=javax.swing.ImageIcon>
point to..
<http://java.sun.com/docs/books/tutorial/uiswing/misc/icon.html>
..which explains..
"Swing provides a particularly useful
implementation of the Icon interface:
ImageIcon, which paints an icon from
a GIF, JPEG, or (as of 1.3) PNG image."
Note that 'tif' is not listed..
For some examples of reading 'tif's, you might check
<http://www.geocities.com/marcoschmidt.geo/java-image-file-code-examples.html>
HTH

Signature
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
Andrew Thompson - 16 May 2004 16:56 GMT
Of course.. I _could_ have solved that on the
first post if I had been paying attention!
".tif dilema" / ImageIcon..
D'Uh! (slaps forehead)

Signature
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology