Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6356869

REGRESSION: Applet in a hidden div does not repaint properly with div is shown

XMLWordPrintable

    • 5.0
    • x86
    • windows_xp

      FULL PRODUCT VERSION :
      java version "1.5.0_04"

      ADDITIONAL OS VERSION INFORMATION :
      Windows XP
      Windows 2000
      Windows 2003

      A DESCRIPTION OF THE PROBLEM :
      In a page like:

      <div style='display: block'>
      <applet ... >
      </div>
      <div style='display: none'>
      <applet ...>
      </div>
      <div style='display: none'>
      <applet ...>
      </div>

      When any subsequent <DIV> is shown, and the first one is hidden, the applet within the <DIV> doesn't repaint properly the first time it is shown. You still see the first applet on the screen, even though you should be seeing the second one.

      I tried with both Applet and JApplet subclasses, but the behavior was the same both times.

      This behavior worked in 1.4.1, but it no longer working in the latest 1.5 version.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      With the attached HTML page and Java applet code:

      1) In the HTML window, click on the Applet 2 button.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      When you click the Applet 2 button, you should see an applet with a label saying Second Applet.
      ACTUAL -
      You still see an applet with a label saying First Applet.

      If you click on the "Applet 1" button and then on the "Applet 2" button again, you will see the proper applet.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      No error messages given

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      APPLET SOURCE CODE:

      package test;

      import java.awt.*;
      import javax.swing.*;

      public class StringApplet2 extends javax.swing.JApplet {

      /** Creates a new instance of StringApplet2 */
      public StringApplet2() {
      }

      /** String to display in the applet. */
      private String theString;

      /** Initialization method that will be called after the applet is loaded
      * into the browser.
      */
      public void init() {
      theString = getParameter("string");
      getContentPane().setLayout(new BorderLayout());
      JLabel l = new JLabel();
      l.setText(theString);
      getContentPane().add(l, BorderLayout.NORTH);
      validate();
      }
      }


      HTML PAGE:
      <HTML>
      <HEAD>
      <TITLE>Hidden Applet Tester</TITLE>
      <script>

      function setVisible(vType) {
      if (vType == 1) {
      document.getElementById("appletDiv1").style.display = 'block';
      document.getElementById("appletDiv2").style.display = 'none';
      } else {
      document.getElementById("appletDiv2").style.display = 'block';
      document.getElementById("appletDiv1").style.display = 'none';
      }
      }

      </script>
      </HEAD>
      <BODY>
      <table border='0' cellspacing='0' cellpadding='5'>
      <tr>
      <td valign='top'>
      <input type='button' value='Applet 1' onclick='setVisible(1)'><br>
      <input type='button' value='Applet 2' onclick='setVisible(2)'>
      </td>
      <td>
      <div id='appletDiv1' style='display: block'>
      <applet width='200' height='200' code='test.StringApplet2' codebase='applets'>
      <param name='string' value='First Applet'>
      </applet>
      </div>
      <div id='appletDiv2' style='display: none'>
      <applet width='200' height='200' code='test.StringApplet2' codebase='applets'>
      <param name='string' value='Second Applet'>
      </applet>
      </div>
      </td>
      </tr>
      </table>
      </BODY>
      </HTML>
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      None, other than pressing the buttons again.

      Release Regression From : 1.4.1
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.

            Unassigned Unassigned
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: