The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
December 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

From my experience

Posted by Hiran on December 25, 2001 at 2:22 PM

I've found that images load much faster if an ImageIcon object is used instead. One of ImageIcon's constructors is to create an ImageIcon object using the URL or pathname of an image file. Then an Image object can be created using the getImage method in the ImageIcon class.
Hiran


>
> > If I have the following:
> > Toolkit.getDefaultToolkit().getImage("C:\\dir\\picture.bmp");
> > How can I then Display it on the screen?
> > Thank you.
>

> You can look at the
> Overview of Custom Painting to learn how to draw images on JPanels, but you have a more fundamental problem to address first: ToolKit.getImage() only supports GIF, JPEG or PNG file formats. So you either have to convert your BMP files to one of these, or find some third-party tool that reads BMPs in to Images (maybe Microsoft has a class for this, but it may also require their JVM).

> - mfg





Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us