For Programmers: Free Programming Magazines  


Home > Archive > Java Help > May 2004 > .tif dilema









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author .tif dilema
Scott Collier

2004-05-16, 12:31 pm

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



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.686 / Virus Database: 447 - Release Date: 14/05/04


Andrew Thompson

2004-05-16, 12:31 pm

On Sun, 16 May 2004 15:05:46 GMT, Scott Collier wrote:

> 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.

--
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

2004-05-16, 12:31 pm

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"



"Andrew Thompson" <SeeMySites@www.invalid> wrote in message
news:1dvhlah7q5wl4.u04h56l1kvoy.dlg@40tude.net...
> On Sun, 16 May 2004 15:05:46 GMT, Scott Collier wrote:
>
>
> What have you tried Scott, got an example?
> <http://www.physci.org/codes/sscce.jsp>
>
>
> Please tell us any stacktrace or
> exact results you are getting..
> <http://www.physci.org/codes/javafaq.jsp#exact>
>
>
> It is fairly easy, though there are a few
> 'gotchas'. Need some more info. to give you
> more specific advice.
>
> --
> Andrew Thompson
> http://www.PhySci.org/ Open-source software suite
> http://www.PhySci.org/codes/ Web & IT Help
> http://www.1point1C.org/ Science & Technology



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.686 / Virus Database: 447 - Release Date: 14/05/04


Andrew Thompson

2004-05-16, 12:31 pm

On Sun, 16 May 2004 15:38:32 GMT, Scott Collier wrote:[color=darkred]
> "Andrew Thompson" <SeeMySites@www.invalid> wrote in message

Ahh.. wait, think I have (now) spotted the problem.

The JavaDocs for ImageIcon (links here..)
<http://www.physci.org/api.jsp?class...swing.ImageIcon>
point to..
<http://java.sun.com/docs/books/tuto.../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/marcoschmi...e-examples.html>

HTH

--
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

2004-05-16, 12:31 pm

Of course.. I _could_ have solved that on the
first post if I had been paying attention!

".tif dilema" / ImageIcon..

D'Uh! (slaps forehead)

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







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com