Article View: borland.public.jbuilder.java.language
Article #19976Re: Simple question about static references
From: Chris Clayton
Date: Sun, 09 Nov 1997 00:00
Date: Sun, 09 Nov 1997 00:00
32 lines
1791 bytes
1791 bytes
Chris Clayton wrote: > I am writing an application, and I've generated the UI just > fine. I created a new Panel class (PaintPanel) derived from > BevelPanel, > and wrote the appropriate paint() routine. A number of the > variables in that routine are defined in the DemoFrame1 class > generated by JBuilder from the Design view. I qualified > them each time I used them as DemoFrame1.WindowSize > (as an example). When I build, however, each of these > variables gets the error: cannot make a static reference to > non-static variable WindowSize. > > Now, WindowSize is non-static because it exists in an > instance of DemoFrame1. But when PaintPanel is > instantiated in the DemoFrame1 constructor, it isn't > a static class either. Can anyone help me figure out > why I'm getting this error? Many thanks! Well, I'm still not entirely sure of *why* I'm getting the error, but I did figure out how to get rid of it. I borrowed a technique from one of the demos, and defined a setParent(DemoFrame1 p) function in the new PaintPanel class, and included a Panel1.setParent(this) in the DemoFrame1 jbInit routine. With this reference passed, and all of the variables in the PaintPanel class referenced to the parent.variable, it all compiles nicely. Live and learn.... -- Chris Clayton clayton@rust.net
Technical Details
Message-ID:
<34661C6F.14A46572@rust.net>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<3465537D.BD4987A9@rust.net>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,802d223961fbc908 X-Google-Attributes: gidf74b3,public From: Chris Clayton <clayton@rust.net> Subject: Re: Simple question about static references Date: 1997/11/09 Message-ID: <34661C6F.14A46572@rust.net> X-Deja-AN: 288131934 References: <3465537D.BD4987A9@rust.net> Organization: None Reply-To: clayton@rust.net Newsgroups: borland.public.jbuilder.java.language