gettingstarted
[Top] [All Lists]

Re: g.stringWidth() NilObjectException

To: Getting Started <gettingstarted at lists dot realsoftware dot com>
Subject: Re: g.stringWidth() NilObjectException
From: Aaron Ballman <aaron at realsoftware dot com>
Date: Wed, 29 Sep 2004 19:10:20 -0500
Delivered-to: gettingstarted at lists dot realsoftware dot com
References: <C084543A-1269-11D9-ACA3-000A95B8E76E at bellsouth dot net> <EADFE9D8-1274-11D9-A04F-000A95983FBE at ljug dot com>
Why do I get a NilObjectException on the g.TextFont line?


Because g is a reference to a Graphics object, and the current value of g, as far as I can see, is Nil. When you try to access an object through a Nil reference, you get a NilObjectException.

Also note that you cannot just say g = new Graphics since RB does not have the concept of memory-only graphics objects.

Your best bet is do use the window's graphics object like this:

dim g as Graphics
g = MyWindow.Graphics

...

HTH!

~Aaron
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>