Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6643769
Votes 0
Synopsis Applet main windows steals focus on Popup windows which is running Applet.
Category java_plugin:other
Reported Against
Release Fixed 6u12(b02), 6u11-rev(b04) (Bug ID:2170094) , 5.0u17-rev(b09) (Bug ID:2170095) , 5.0u18(b01) (Bug ID:2171617)
State 11-Closed, Verified, bug
Priority: 2-High
Related Bugs 6662588 , 6770457 , 6788540
Submit Date 19-DEC-2007
Description
FULL PRODUCT VERSION :
1.4.2_06, 1.5.0_06-13, 1.6.0, and 1.6.0_1-3

ADDITIONAL OS VERSION INFORMATION :
Windows XP

A DESCRIPTION OF THE PROBLEM :
User run the Applet on main page, and then he pop up windows which run Applet also. When the main page is refreshed automatically, the main page steal focus from the pop up windows.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Step to Reproduce:

1. Launch TestMainApplet.html
2. Click link “Test Popup with Applet” and focus this windows.
3. Wait 5 seconds.

Note: From step 2, if you click with “Test Popup without Applet”, you cannot replicate problem since 1.5.0.



EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Whenever TestMainApplet.html is refreshed, the “Test Popup with Applet” window is still focused.
ACTUAL -
Whenever TestMainApplet.html is refreshed, the “Main Test Refresh” window is focused back.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
//Source code HelloWorldApplet.java:

import java.applet.*;
import java.awt.*;
  
public class HelloWorldApplet extends Applet
{ 
     public void init()
     {
     }
  
     public void stop()
     {
     }

     public void paint(Graphics g)
     {
      g.drawString("Hell World",20,20);
     }

} 

//Source code HelloWorldApplet2.java:

import java.applet.*;
import java.awt.*;
  
public class HelloWorldApplet2 extends Applet
{ 
     public void init()
     {
     }
  
     public void stop()
     {
     }

     public void paint(Graphics g)
     {
      g.drawString("Hell World2",0,20);
     }

} 

//Source code TestMainApplet.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Main Test Refresh Applet </TITLE>
<meta http-equiv="REFRESH" content="5">
</HEAD>
<BODY>
<applet code="HelloWorldApplet.class">
<param name="cache_archive_ex" value="HelloWorldApplet.jar">
<param name=initial_focus value="true">
</applet>
<a href="TestApplet2.html" target="Test">Test Popup with Applet</a>
<a href="TestPopupwithoutApplet.html" target="Test">Test Popup without Applet</a>
</BODY>
</HTML>
////////////////////////

//Source code TestApplet2.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Test Popup with Applet </TITLE>
<META NAME="Generator" CONTENT="EditPlus">

</HEAD>

<BODY>
<applet code="HelloWorldApplet2.class">
<param name="cache_archive_ex" value="HelloWorldApplet.jar">
</applet>
</BODY>
</HTML>
///////////////////////////////////


//Source code TestPopupwithoutApplet.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Test Popup withou Applet </TITLE>
</HEAD>
<BODY>
<p>Popup without Applet</p>
</BODY>
</HTML>
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Disable refresh automatically on main page.
Posted Date : 2007-12-19 14:52:20.0
Work Around
N/A
Evaluation
I can easily reproduce the problem with at least JDK7. There is no clear specification for this particular case, so I can't say for sure, what is the right behavior: should the main page steal focus or not. My own opinion is it shouldn't, regardless of the second page contains any applet or not.
Posted Date : 2007-12-28 12:50:00.0

In the sun.applet.AppletPanel class, on receiving the APPLET_START message the applet
requests focus by default. On reloading the applet in the browser, this message is
sent to the applet ones again and it requests focus. Distinguish these two cases
(first start and reload) is in scope of the plugin, so I'm reassigning the CR.
(By the way, the testcase uses initial_focus param set to true in the applet).

Why the applet doesn't steal focus from non-applet window since 1.5
I can think of two reasons.
1) In that release there have been changed the way the EmbeddedFrame is
activated.
2) The window belongs to a different thread in contrast to the window with
applet (the latter has active EmbeddedFrame inside that belongs to the same
thread).
This problem is a separate issue though.
Posted Date : 2008-01-22 12:08:13.0

The problem is caused by the synthetic window activations we are asking the AWT to perform on the EmbeddedFrame containing the applet. Commenting out the call to JVMManager.getManager().synthesizeWindowActivation() in IExplorerPlugin.OnFrameWindowActivate(), deploy/src/plugin/share/classes/sun/plugin2/main/server/IExplorerPlugin.java, solves the problem at least with IE 7 on my end.

The sending of synthetic window activations upon this event dates back to the classic Java Plug-In (see CAxControl::OnFrameWindowActivate(), deploy/src/plugin/win32/com/iexplorer/AxControl.cpp). However, we found that sending this event upon deactivation was the wrong thing to do earlier in the 6u10 release (see the comments in IExplorerPlugin.OnFrameWindowActivate and bug 6662588) and it may well be that we should simply ignore the OnFrameWindowActivate event altogether.

At least in the new plugin the fix appears to be very simple and we should get it in the hands of the customer as quickly as possible to resolve the escalation.
Posted Date : 2008-11-12 02:06:09.0

By the way, this fix works in conjunction with specifying the "initial_focus" applet parameter to be "false", to prevent the plugin from attempting to grab the focus via another synthetic window activation.
Posted Date : 2008-11-12 02:23:18.0

A fix is in the InPlaceActivate method of our activeX control, we should check if the iVerb is OLEIVERB_SHOW before calling ::SetFocus. Same fix applies to both old and new plugin.
Posted Date : 2008-11-18 01:13:23.0
Comments
  
  Include a link with my name & email   

Submitted On 28-OCT-2009
dcarpen
It's interesting that with Java 1.6 focus works correctly with the applet popup window when the popup window is opening a Word document. This does not work properly when opening an html page or an Excel document using this method, as the main window steals focus. Is this somehow related to a timing issue? Better yet, do you have a fix in the works yet? 
This negatively affects my program. Thanks, Don Carpenter: don.carpenter@xerox.com



PLEASE NOTE: JDK6 is formerly known as Project Mustang