How to make casting.....

If I take Image with Tookit class, How can i make this Image as a BufferedImage?

Like:

Image image = Tookit.getDefaultToolkit().getImage("image.jpg");

BufferedImage bi = (BufferedImage)image;

and the result of that is ClassCastException, so the cast is invalid. Is there any way to do this cast in different way?

[368 byte] By [Pawa] at [2007-10-3 8:56:16]
# 1

> and the result of that is ClassCastException, so the

> cast is invalid. Is there any way to do this cast in

> different way?

Either you cast or you don't. If what Toolkit returns isn't a BufferedImage, there's no way to cast it to one. You could create a BufferedImage of the same size and paint Toolkit's image onto it.

CeciNEstPasUnProgrammeura at 2007-7-15 4:06:31 > top of Java-index,Java Essentials,Java Programming...
# 2
Thank you againt!I will try it. ps. How can I earn more those duke dollars for at giving ;) ?
Pawa at 2007-7-15 4:06:31 > top of Java-index,Java Essentials,Java Programming...
# 3

> ps. How can I earn more those duke dollars for at

> giving ;) ?

Earning Duke Dollars is hard these days. Many don't offer them at all, others offer them but forget about assigning them. And if you really want to become wealthy, create multiple accounts and have them ask questions you answer with your real acccount. That way you can assign yourself dukes. :)

In other words, don't bother, they're worthess. A post saying "thanks, that helped" or "thanks I did: ..." is just as nice and more helpful to people who read the thread later.

CeciNEstPasUnProgrammeura at 2007-7-15 4:06:31 > top of Java-index,Java Essentials,Java Programming...