United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6753647 Dismiss modal dialog, focus erroneously goes to Internet Explorer 7 window
JDK-6753647 : Dismiss modal dialog, focus erroneously goes to Internet Explorer 7 window

Details
Type:
Bug
Submit Date:
2008-09-29
Status:
Closed
Updated Date:
2012-03-15
Project Name:
JDK
Resolved Date:
2010-12-04
Component:
deploy
OS:
windows_vista,windows_xp
Sub-Component:
plugin
CPU:
x86
Priority:
P2
Resolution:
Fixed
Affected Versions:
5.0,5.0u17,5.0u17-crev
Fixed Versions:
5.0u17-crev (b04)

Related Reports
Backport:
Duplicate:

Sub Tasks

Description
FULL PRODUCT VERSION :
java version "1.5.0_14"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_14-b03)
Java HotSpot(TM) Client VM (build 1.5.0_14-b03, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
After dismissing a modal dialog with a JFrame parent, focus is erroneously returned to the applet host browser. This is only a problem when using Internet Explorer 7. Works correctly with IE6, and Firefox.
This is only a problem with Java 1.5.0_14 and up.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
  To Reproduce Bug:
Run an applet in Internet Explorer 7 that opens a JFrame window.
  From window, open a modal dialog.
Dismiss modal dialog.


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expected Result:
Focus returns to the dialog's parent, the JFrame window.
ACTUAL -
Actual Result:
Focus returns to Internet Explorer 7.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
------------------- javaBug.html -------------------------
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<TITLE>
Demo JRE 1.5_0.14 Plugin bug for IE7.
</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">

<CENTER>
<OBJECT classid="clsid:CAFEEFAC-0015-0000-0014-ABCDEFFEDCBA"
	WIDTH = "300"
	HEIGHT = "100"
	codebase="http://localhost/jre-1_5_0_14-windows-i586-p.exe#Version=1,5,0,14"
	STANDBY="Please wait, while your browser downloads the required files.">

<PARAM NAME = "type" VALUE="application/x-java-applet;version=1.5.0_14">
<PARAM NAME = CODE     VALUE = "com.javasoft.JavaBug.class">
<PARAM NAME = CODEBASE VALUE = "http://localhost/javabug/">
<PARAM NAME = NAME     VALUE = "JavaBug">
<PARAM NAME = HSPACE   VALUE = "0">
<PARAM NAME = VSPACE   VALUE = "0">
<PARAM NAME = ALIGN    VALUE = "top">
<PARAM name = progressbar value = "true">

<COMMENT>
<EMBED type="application/x-java-applet;jpi-version=1.5.0_14"
	 java_CODE = "com.javasoft.JavaBug.class"
	 java_CODEBASE = "http://localhost/javabug/"
		NAME = "JavaBug"
		HSPACE = "0"
		VSPACE = "0"
		HEIGHT = "500"
		ALIGN = "top">
</COMMENT>

<NOEMBED>
Error loading Applet, please ensure your web browser <BR>
1. &nbsp Supports HTML version 4.0 <BR>
2. &nbsp You have the Java Plugin version 1.5.0_14 installed<BR>
</NOEMBED>
</EMBED>
</OBJECT>
</CENTER>
</BODY>
</HTML>



------------------------ JavaBug.java -------------------------

package com.javasoft;

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

public class JavaBug extends Applet
{
	JButton button;
	MyFrame frame;
	public void init()
	{
		button = new JButton("Open Window");
		button.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent ae){
				button.setEnabled(false);

				frame = new MyFrame("Demo Modal Dialog/IE7 Bug");
				frame.setVisible(true);
			}
		});
		add(button, null);
	}


	class MyFrame extends JFrame
	{
		JButton frameButton;
		JDialog frameDialog;
		public MyFrame(String title)
		{
			setTitle(title);
			setLayout(new BorderLayout());

			frameButton = new JButton("Display Modal Dialog");
			frameButton.addActionListener(new ActionListener(){
				public void actionPerformed(ActionEvent ae){
					frameButton.setEnabled(false);

					frameDialog = new JDialog(MyFrame.this, "Modal Dialog", true);
					frameDialog.setLayout(new BorderLayout());
					frameDialog.add(new JLabel("This is a modal dialog"), BorderLayout.NORTH);
					

					JButton closeButton = new JButton("Close");
					closeButton.addActionListener(new ActionListener(){
						public void actionPerformed(ActionEvent ae){
							frameDialog.setVisible(false);
						}
					});
					frameDialog.add(closeButton, BorderLayout.SOUTH);
					frameDialog.pack();

					frameDialog.setVisible(true);
				}
			});
			add(frameButton, BorderLayout.SOUTH);


			JTextArea text = new JTextArea();
			text.setColumns(30);
			text.setRows(10);
			text.setText("This window should regain focus\nafter dismissing modal dialog");
			JScrollPane scroll = new JScrollPane(text);
			add(scroll, BorderLayout.CENTER);

			pack();
		}
	}
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Back down to Java 1.5.0_13, as our clients are using Internet Explorer 7.

Release Regression From : 5.0u13
The above release value was the last known release where this 
bug was not reproducible. Since then there has been a regression.

                                    

Comments
EVALUATION

Apologies for the late evaluation.

This was caused by 6542420. I've attached two spy logs. (one for 1.5.0_13 where everything wroks normally and one for 1.5.0_14 where it is broken)

I'm hoping the AWT team can help shine some light on the results. Points of note:

- in _13 lines 27 & 62 point to the same "hwndPrevious" - 000C0366. Line 54 points to 000D02CC.
- in _14 lines 27 & 54 point to the same hwnd (00060246) but 62 points to null.

Note: the spy++ output seems to insert a lot of control characters, but gedit opened these docs in a viewable manner.
                                     
2010-03-08
EVALUATION

I should add, the first two line breaks at lines 31 & 38 in the log files represent the second and third (last) clicks in the testcase.
                                     
2010-03-08



Hardware and Software, Engineered to Work Together