JDK-6963024 : Only Applets on Windows: two JOptionPanes in a row makes the 2nd JOptionPane flicker
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6u20
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: windows
  • CPU: generic
  • Submitted: 2010-06-22
  • Updated: 2011-03-10
  • Resolved: 2010-10-26
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7
6u22-rev b07Fixed 7Resolved
Description
Java (6u20) Applet on Windows (XP SP 2|XP SP 3|Vista|7) in IE (7|8) or FF (3.6.3).
If not mentioned explicitly, configurations not mentioned here don't indicate that there is not a problem with those configs. If you want to check whether the bug exists also in your environment, download the testcase and run it.

The problem is that flickering (and sound) occurs whenever software opens two JOptionPanes in a row. 

    JOptionPane.showMessageDialog(AppletTest.this, "Test 1");
    JOptionPane.showMessageDialog(AppletTest.this, "Test 2");

The first is ok, but if a second follow-up JOptionPane is displayed it always flickers a short time. If the environment supports sound, the user also hears the warning sound of Windows. That behavior (flickering and warning sound) irritates customers actually. 

It is not reproducible when using an Application instead of an Applet. 
(StandaloneTest.java is attached)

It is not reproducible on Solaris.

If the second JOptionPane is shown within SwingUtilities.invokeLater is does not (always) flicker. However, that workaround does not always work. And the customer do not wish to use invokeLater every time a JOptionPane should be shown.

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            JOptionPane.showMessageDialog(AppletTest.this, "Test 3");
        }
    }

Runnable Testcase is attached. For IE browsers, open AppletTestForIE.html, for FF browsers, open AppletTestForFF.html.

Comments
EVALUATION The flicker is happening because, the 2nd JOptionPane gets rendered while the 1st JOPtionPane blocks the applet with its modal dialog. Hence there is an attempt to raise the blocker to front by invoking ModalityHelper.reactivateDialog(blocker), in the below code snipped from PluginMain.handleMessageSynthesizeWindowActivation(): Dialog blocker = getModalDialogForApplet(appletID); if (blocker != null) { blocker.toFront(); blocker.requestFocus(); if (DEBUG) { System.out.println(" Called Dialog.toFront() / requestFocus() for blocker of applet ID " + appletID); } if (lastReactivationTime == 0 || System.currentTimeMillis() > lastReactivationTime + MIN_REACTIVATION_DELAY) { ModalityHelper.reactivateDialog(blocker); lastReactivationTime = System.currentTimeMillis(); } The System.currentTimeMillis() is > than lastReactivationTime + MIN_REACTIVATION_DELAY for this testcase. Raising the value to 1000 does not help.
24-08-2010

WORK AROUND Wrap the method by SwingUtilities.invokeLater SwingUtilities.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(AppletTest.this, "Test 3"); } } Note that this workaround might not work always.
22-06-2010