Hello to All
Could someone tell me why
Graphics g = getGraphics();
would equal zero
I know it should equal something like
sun.java2d.SunGraphics2D[some other stuff in here]
I am completly stumped on this one
BOB8000
Efi Merdler - 17 Mar 2007 17:29 GMT
> Hello to All
>
[quoted text clipped - 11 lines]
>
> BOB8000
Hi,
Make sure you are calling getGraphics after the form was initialized
and displayed.
Efi
Knute Johnson - 17 Mar 2007 17:31 GMT
> Hello to All
>
[quoted text clipped - 11 lines]
>
> BOB8000
Are you calling getGraphics() on a Component? Is it visible? Do you
know where to find the API documentation?

Signature
Knute Johnson
email s/nospam/knute/
Nigel Wade - 19 Mar 2007 10:48 GMT
> Hello to All
>
> Could someone tell me why
>
> Graphics g = getGraphics();
Called on what?
Has whatever you are invoking the method on been realized? A component which
hasn't yet been realized has no Graphics, and getGraphics() will return null.
> would equal zero
zero, or null? It should never be zero.
> I know it should equal something like
>
> sun.java2d.SunGraphics2D[some other stuff in here]

Signature
Nigel Wade, System Administrator, Space Plasma Physics Group,
University of Leicester, Leicester, LE1 7RH, UK
E-mail : nmw@ion.le.ac.uk
Phone : +44 (0)116 2523548, Fax : +44 (0)116 2523555
Tor Iver Wilhelmsen - 22 Mar 2007 19:41 GMT
På Sat, 17 Mar 2007 17:08:37 +0100, skrev bob8000 <bob8000@hotmail.co.uk>:
> Could someone tell me why
>
> Graphics g = getGraphics();
>
> would equal zero
You mean null? getGraphics() returns null until the component has a
"peer". If you need to pick it up for some code, either do so in
addNotify() or in paint()/paintComponent(), though the latter might be
"too late" for your needs.