Microsoft KB Archive/163721

= FIX: Controls Not Visible in a JAVA Application =

Article ID: 163721

Article Last Modified on 5/12/2007

-

APPLIES TO


 * Microsoft Visual J++ 1.0 Standard Edition

-



This article was previously published under Q163721



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.



Steps to Reproduce Behavior
 Create a default Java Applet Wizard application and check the option of creating both an applet and an application. Insert a dialog resource using Insert.Resource. Add a few controls to the dialog resource. Close the Dialog Editing window. Save the resource file as an .rct file. From the Tools menu run Java Resource Wizard.</li> In the File name box, specify the .rct file that you created in step 5 and click Finish.</li> 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.</li>  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 </li>  Also instantiate a NewDialog class object near the beginning of the applet declaration: NewDialog dlg=null; </li>  In the applet's init method, remove the call to resize and add the following lines: dlg = new NewDialog(this); dlg.CreateControls; </li> Now build the Java project.</li> 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.</li></ol>

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.

<div class="references_section">