BUG: NullPointerException in DialogLayout Constructor

Last reviewed: January 29, 1998
Article ID: Q167942
The information in this article applies to:
  • Microsoft Visual J++, versions 1.0, 1.1

SYMPTOMS

When you try to call your Dialog class constructor and CreateControls() in a Frame Class constructor, the following error appears:

   Java.lang.NullPointerException.

CAUSE

The font for the frame has not been initialized.

RESOLUTION

To workaround the problem create a font object prior to the call to the Dialog box constructor. For example:

   import java.awt.*;
   import NewDialog;

   class MyFrame extends Frame
   {
      NewDialog dlg = null;
      public MyFrame()
      {

         setFont( new Font( "Dialog", Font.PLAIN, 16));

         dlg = new NewDialog(this);
         dlg.CreateControls();
      }
   }

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Generate an Applet using VJ1.0/1.1 AppletWizard. Remove the multi-threaded option and leave everything else as default.

  2. Create a new Dialog resource named NewDialog with the default OK and Cancel buttons on it. Save it as a .rct file.

  3. Run Java Resource Wizard to create the corresponding .java files.

  4. Create a new class called MyFrame and extend it from frame:

          import java.awt.*;
          import NewDialog;
    

          class MyFrame extends Frame
          {
    
             NewDialog dlg = null;
             public MyFrame()
             {
                dlg = new NewDialog(this);
                dlg.CreateControls();
             }
          }
    
    

  5. In the Applet class instantiate the frame class as:

          MyFrame frame = null;
    

  6. In the Applets init() function call:

          frame = new MyFrame();
          frame.show();
    

When you run this applet, the NullPointerException error appears.

REFERENCES

For the latest Knowledge Base articles and other support information on Visual J++ and the SDK for Java, see the following page on the Microsoft Technical Support site:

   http://support.microsoft.com/support/visualj/
   http://support.microsoft.com/support/java/


Additional query words: NullPointerException java

Keywords : kbtool VJGenIss WizardIss kbbuglist
Technology : kbInetDev
Version : 1.0 1.1
Platform : WINDOWS
Issue type : kbbug


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: January 29, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.