FIX: Controls Not Visible in a JAVA Application

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

SYMPTOMS

Controls in a dialog resource, created using the Java Resource Wizard in a java application do not appear when the java application is loaded.

RESOLUTION

To work around the problem, move the call to resize the frame in main() in the AppWizard generated code to the end of function main(). Following is the AppWizard generated code modified with the workaround:

   ...
      public static void main(String args[])
      {
...
         frame.show();
        frame.hide();


   // Move the following call to the end of the function
   //    frame.resize(frame.insets().left + frame.insets().right
   //                           + 320,
   //                           frame.insets().top  + frame.insets().bottom
   //                           + 240);

   ...
      applet_resj.start();
      frame.show();


   // After modification
   frame.resize(frame.insets().left + frame.insets().right
                             + 320,
                             frame.insets().top  + frame.insets().bottom
                             + 240);

      }
   ...

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem has been fixed in Visual J++ 1.1.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a default Java Applet Wizard application and check the option of creating both an applet and an application.

  2. Insert a dialog resource using Insert.Resource.

  3. Add a few controls to the dialog resource.

  4. Close the Dialog Editing window.

  5. Save the resource file as an .rct file.

  6. From the Tools menu run Java Resource Wizard.

  7. In the File name box, specify the .rct file that you created in step 5 and click Finish.

  8. The Resource Wizard now creates a .java file containing a class whose name is the ID of the dialog. The Resource Wizard also creates a separate file for a DialogLayout class.

  9. Now open the Java source file of your main Java project and add the following import statement to the beginning of the file:

          import NewDialog;   // NewDialog is the ID of the Dialog resource
    
    

  10. Also instantiate a NewDialog class object near the beginning of the applet declaration:

          NewDialog dlg=null;
    

  11. In the applet's init method, remove the call to resize and add the following lines:

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

  12. Now build the Java project.

  13. Go to the command prompt and run jview on the project to run this as a stand-alone application.

        -or-
    

    Choose Build.Setting and select the Debug Tab. Click General in the Category drop-down box. Specify the class name under Class for debugging/executing edit box. Also select the option button corresponding to Stand-alone interpreter (application only). Now execute the Java Application from within MSDEV.

You will notice that the controls that you added do not appear when the application loads. The problem doesn't happen when run as an applet.

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/

Keywords          : kbtool WizardIss
Technology        : kbInetDev
Version           : 1.0
Platform          : WINDOWS
Issue type        : kbbug
Solution Type     : kbfix


================================================================================


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.