double image buffering

ok when i run this code in an applet it works fine, but as a fram outside an applet i get a null pointer exception...wut is it that i dont know?

Image offscreen;

offscreen = this.creatImage(800, 600);

Graphics g = offscreen.getGraphics();<== here is my null pointer exception

the only difference is one "extends Applet" and the other "extends Frame" the description of the methods are identical. thnx

[434 byte] By [noone392a] at [2007-10-2 17:56:33]
# 1
Your Window must be displayable, i.e. showing on screen, before you can call that code.
da.futta at 2007-7-13 19:15:15 > top of Java-index,Java Essentials,Java Programming...
# 2
wow such a simple solution for all that struggle...thanks a bunch
noone392a at 2007-7-13 19:15:15 > top of Java-index,Java Essentials,Java Programming...
# 3

> wow such a simple solution for all that

> struggle...thanks a bunch

:-) It's all in the Javadoc:

/**

* Creates an off-screen drawable image

*to be used for double buffering.

* @paramwidth the specified width

* @paramheight the specified height

* @returnan off-screen drawable image, which can be used for double

*buffering. The return value may be <code>null</code> if the

*component is not displayable. This will always happen if

*<code>GraphicsEnvironment.isHeadless()</code> returns

*<code>true</code>.

* @see #isDisplayable

* @see GraphicsEnvironment#isHeadless

* @sinceJDK1.0

*/

(Or [url http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Component.html#createImage(int,%20int)]here[/url])

da.futta at 2007-7-13 19:15:15 > top of Java-index,Java Essentials,Java Programming...