🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #16634

qtn in calling the constructor of super-class

#16634
From: Vasudevan Srinivasan
Date: Thu, 04 Feb 1999 00:00
50 lines
1766 bytes
Hi
I have got a class like this:

class MyClass {
    MyFrame frame;
    MyDialog dialog;

    MyClass() { ...  }

    public void showFrame() {
        if (frame != null) frame = new MyFrame();
    }

    public void showDialog() { // called from main()
        if (frame != null) {
            dialog = new MyDialog();
            dialog.show();
        }
    }

    //Inner class MyFrame
   class MyFrame extends Frame {
   ... // contents not important
   }

   //Inner class MyDialog
   class MyDialog extends Dialog {
       //constructor
       MyDialog() {
        super(frame, "Title", true /*modal*/ );  // <=== Compiler fails
here saying "cant reference variable frame
                                                                  //
before super class constructor is called; frame is always a valid
                                                                  //
pointer before dialog is called.
      }
   }
}

But if I pass to MyDialog constructor the frame it works fine. In code
it looks like:
    //constructor
    MyDialog(Frame f) {
        super(f, "Title", true); // <== this works fine
    }

what does the error mean and more importantly why is it an error, can
some one explain?
Thanks
Vasu
Technical Details
Message-ID: <36B9E172.CEF061D5@hotmail.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,65371036b7bc4e61,start
X-Google-Attributes: gidf74b3,public
From: Vasudevan Srinivasan <vasya10@hotmail.com>
Subject: qtn in calling the constructor of super-class
Date: 1999/02/04
Message-ID: <36B9E172.CEF061D5@hotmail.com>
X-Deja-AN: 440670411
Content-Transfer-Encoding: 7bit
Organization: NetRisk Inc
Content-Type: text/plain; charset=us-ascii
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language