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 / First Aid / May 2004

Tip: Looking for answers? Try searching our database.

.tif dilema

Thread view: 
Scott Collier - 16 May 2004 16:05 GMT
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
Andrew Thompson - 16 May 2004 16:29 GMT
> 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



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.