ID: Q163721
The information in this article applies to:
Controls in a dialog resource, created using the Java Resource Wizard in a java application do not appear when the java application is loaded.
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);
}
...
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.
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.
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 kbwizard kbMFC kbVC
Version : 1.0
Platform : WINDOWS
Issue type : kbbug
Solution Type : kbfix
Last Reviewed: January 31, 1998