Knute Johnson wrote:
Component.createImage() returns an Image according to the docs but it
is really a BufferedImage. Does anybody know where to find that
information in the docs?
I think it was once written down in some Sun tutorial, but I can't find
it at the moment. I have never noticed it in the API spec.
IMHO, unless you really need the image for double-buffering a particular
Component-instance's data, using Component.createImage() is not a great
choice.
The alternatives are unfortunately not to great, too.
BufferedImage constructors are annoying, and you can pick an image type
which is difficult to render (time consuming, with losses) on your screen.
Component.getGraphicsConfiguration().createCompatibleImage()
delivers a BufferedImage which is best configured for being bit-blitted
on the screen, but only works if the component has already been added to
a component hierarchy which ends up at some Window subclass, or if the
Component is a Window subclass.
If you want to avoid that trouble, you can get a BufferedImage which is
best configured for being bit-blitted on the default screen in its
default configuration by:
GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration()
.createCompatibleImage(...)
:-)
/Thomas
the latter technique is what I used to get my BufferedImages. I had run
into multiple problems in the past using Component.createImage().
the Red Rock Race and Sports book in Summerlin. Java live and in color :-).