Add a BufferedImage to a JFrame

Hi,

I've looked around a bit for a method to do this, and I haven't found one. I have a BufferedImage, and I want to add it in some way to a JFrame, so I can display it in my GUI.

The closest thing I've seen is a JLabel, in which I can add an ImageIcon to it, using the constructor. However, ImageIcon does not have a constructor for BufferedImage; it only has a constructor for Image.

Is there a way of simply adding a BufferedImage to a JFrame through use of a JLabel? Is there a way to do it without converting it to Image? If no, how would I convert a BufferedImage to Image? I see Image is an abstract class; would this be as simple as saying:

Image image =new BufferedImage(...);

?

Thanks for any advice you can give.

[805 byte] By [Djaunla] at [2007-11-27 5:49:45]
# 1
A BufferedImage is an Image, so just use it. JLabel label = new JLabel(new ImageIcon(bufferredImage));
bsampieria at 2007-7-12 15:36:43 > top of Java-index,Desktop,Core GUI APIs...
# 2

> A BufferedImage is an Image, so just use it.

>

> JLabel label = new JLabel(new

> ImageIcon(bufferredImage));

Oh.

API:

"public class BufferedImage

extends Image"

Oops. Seems I completely missed that. My bad.

Thanks a lot!

Message was edited by:

Djaunl

Djaunla at 2007-7-12 15:36:43 > top of Java-index,Desktop,Core GUI APIs...