JDK-6231186 : When loading an applet with JVM 1.5 the first time, it steals window focus
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 5.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2005-02-19
  • Updated: 2011-01-19
  • Resolved: 2005-04-18
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.
Other JDK 6
5.0u4Fixed 6 b33Fixed
Related Reports
Relates :  
Description
A customer reported a problem with JDK1.5 applet/plugin on MS-windows 
platform --
when you load as applet page (which refresh itself say every 5 secs),
then you put a window on top (eg outllook express),
when the applet reload the next time, it would steal the focus (the 
browser becomes on top of
the outlook express).  This only happens for the first time, when you 
put the outlook express
window back on top, the browser doesn't pop back up even the applet 
continues to refresh.

This problem looks similiar to 2120929 & 4984794, but this problem
still exist in a nightly build with those bugs fixed 
(/net/dig-dug.east/bigtmp/deployment/1.5.0_03/nightly/2005-02-11).
Therefore a new bug is filed.
This is radiance case #64454762 and apollo escalation #1-6941598.
Customer is Lehman Brothers.

To reproduce:
* install JDK1.5 plugin to a browser (eg. mozilla firefox or IE)
* open a window (such as outlook express or command prompt)
* load http://pts-americas.west/to/pts-java/applet/TestHello.html
* immediately bring up the other app window on top of the browser window
* when the applet refresh itself the next time, it will bring the 
browser window on top
* this focus changing behaviour won't happen again if you bring the 
other window back on top


HelloWorld.java
===============

import java.applet.*;
import java.awt.*;

public class HelloWorld extends Applet
{
    public void paint(Graphics g)
    {
	g.drawString("Hello world!", 50, 25);
    }
}



TestHello.html
==============

<HTML>
<HEAD>
<meta http-equiv="refresh" content="5;url=TestHello.html">
<TITLE>The Hello Applet</TITLE>
</HEAD>
<BODY>
<P>This is an applet </P>
<EMBED type="application/x-java-applet;version=1.5">
<APPLET CODE="HelloWorld.class" WIDTH=150 HEIGHT=50>
</APPLET>
</EMBED>
<P>Bye</P>
</BODY>
</HTML>


###@###.### 2005-2-19 01:01:50 GMT
###@###.### 2005-2-22 23:11:18 GMT

Comments
SUGGESTED FIX ------- EmbeddedFrame.java ------- *** /tmp/sccs.usjxyJ Mon Mar 14 17:30:52 2005 --- EmbeddedFrame.java Mon Mar 14 17:27:37 2005 *************** *** 480,489 **** --- 480,492 ---- else { return getBounds(); } } + public void toFront() {} + public void toBack() {} + private static class NullEmbeddedFramePeer extends NullComponentPeer implements FramePeer { public void setTitle(String title) {} public void setIconImage(Image im) {} public void setMenuBar(MenuBar mb) {} ###@###.### 2005-03-14 14:56:13 GMT
14-03-2005

EVALUATION Looks like the problem is in EmbeddedFrame.synthesizeWindowActivation() call. It takes focus even if it's outside the browser. I think we should check if the focus inside the browser before taking it. ###@###.### 2005-03-02 13:28:15 GMT As Sean Coffey (the RE for the escalated bug) discovered EmbeddedFrame.synthesizeWindowActivation() was not the cause of the problem but toFront() which is called in Window.show(). The right way is just to override toFront in EmbeddedFrame so that it has no effect as it is the correct behaviour for EmbeddedFrame. ###@###.### 2005-03-14 14:26:26 GMT
02-03-2005