BUG: IE Print Creates New Instance of Applet Class to Be Printed

Last reviewed: January 30, 1998
Article ID: Q180046
The information in this article applies to:
  • Microsoft Win32 Virtual Machine for Java
  • SDK for Java, versions 2.0, 2.01
  • Microsoft Internet Explorer versions 4.0, 4.01 for Windows 95
  • Microsoft Internet Explorer versions 4.0, 4.01 for Windows NT 4.0

SYMPTOMS

When printing an HTML-page in Internet Explorer (IE) 4.x that contains a Java applet, IE creates a new instance of the applet class to be printed. In other words, you see only the initial, default state of the applet on the resulting printout and any changes the user made from the default state of the applet are not printed.

RESOLUTION

To workaround this behavior, initialize all new instances of the applet class with the data from the original instance.

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

To reproduce this behavior, the following example can be used:

  1. Copy the following HTML code to a file named SimpleApplet.html:

          <HTML>
          <TITLE>
          SimpleApplet
          </TITLE>
          <BODY>
          Simple Applet<BR>
          <APPLET
    
            CODE     = "SimpleApplet.class"
            WIDTH    = 400
            HEIGHT   = 300>
          </APPLET>
          </BODY>
          </HTML>
    
    

  2. Copy the following Java source to a file named SampleApplet.java:

          // SimpleApplet.java
          import java.awt.*;
          import java.applet.*;
    

          public class SimpleApplet extends Applet {
    

            TextField textfield = new TextField(30);
            Choice choice = new Choice();
    
            public SimpleApplet() {
                    System.err.println("SimpleApplet SimpleApplet() "+this);
            }
    
            public void init() {
              System.err.println("SimpleApplet Applet.init() "+this);
    
              choice.addItem("Option 1");
              choice.addItem("Option 2");
              this.add(textfield);
              this.add(choice);
              validate();
            }
    
            public void start() {
                System.err.println("SimpleApplet Applet.start() "+this);
            }
    
            public void stop() {
                System.err.println("SimpleApplet Applet.stop() "+this);
            }
    
            public void destroy() {
                System.err.println("SimpleApplet Applet.destroy() "+this);
            }
    
            public void finalize() {
                System.err.println("SimpleApplet Applet.finalize() "+this);
            }
          }
    
    

  3. Compile the SimpleApplet.java file using a Java compiler.

  4. Open the SimpletApplet.html file in IE 4.x.

  5. Enter some text in the TextBox and set the Choice control to "Option 2."

  6. Click Print on the File menu in IE 4.x and notice that the printout does not contain the text entered or the nondefault option in the Choice control.

REFERENCES

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

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


Additional query words: print instance applet
Keywords : JCOM JVM VJGenIss VJMisc
Technology : internet
Version : WINDOWS:2.0,2.01,4.0,4.01; Winnt: 4.0,4.01
Platform : WINDOWS winnt
Issue type : kbbug
Solution Type : kbpending


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 30, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.