JDK-4984794 : Invisible applet steals focus from HTML form field (MSIE, Sun plug-in only)
  • Type: Bug
  • Component: deploy
  • Sub-Component: plugin
  • Affected Version: 1.4.1,1.4.2,1.4.2_04,5.0,6
  • Priority: P3
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: windows_nt,windows_2000,windows_xp
  • CPU: x86
  • Submitted: 2004-01-28
  • Updated: 2010-05-28
  • Resolved: 2008-04-14
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 Availabitlity Release.

To download the current JDK release, click here.
Other JDK 6
1.4.2_08Fixed 6u10Resolved
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Name: gm110360			Date: 01/28/2004

java version "1.4.2_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode)

Microsoft Windows XP [Version 5.1.2600]

We've seen this happening for quite some time, so the specific version of IE probably isn't critical. We've also seen it in previous versions of the Java plug-in, including 1.3.x.

*** I submitted this bug 6 weeks ago (on Sept 11, 2003), and it was given an internal review ID of 207044. The confirmation email I received said there was a three week backlog. I still haven't heard the disposition of this report. Thank you. ***

The attached files show how an invisible applet "steals" focus from a form element. We have an applet on a page that performs some processing when called from JavaScript, but we don't want the applet itself to be visible on the page. Fortunately, we can disable its display by using style="display:none". However, when this applet is on the page, it grabs focus away from the HTML form field. It seems reasonable to us that this would be okay if the applet is visible, but if the applet isn't even being displayed, it shouldn't happen.

TestApplet.java - a very simple applet.
good.html - An HTML file with a single form field. An onload script sets the focus to the form field. As soon as the page comes up, you can start typing, and the characters go into the form field. This is good. bad.html - Same as good.html, with the addition of an invisible applet. When it loads, you can see the cursor flash momentarily in the form field, but then if you start typing your keystrokes are lost. This is bad.

Note that the problem does not occur when using the Microsoft VM (, nor does it occur when using Netscape 7.1. Therefore, it appears to be an interaction between MSIE 6 and the Sun Plug-in.

See description above. Just open bad.html in MSIE 6. When the page comes up, start typing. The characters go nowhere.

When the page comes up, the characters you type should go into the form field.
When the page comes up, the characters you type go nowhere.

This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.applet.*;

public class TestApplet extends Applet
	public TestApplet ()
		System.err.println( "TestApplet" );

	public void init()
		System.err.println( "TestApplet init" );
	public void destroy()
		System.err.println( "TestApplet destroy" );


<body onload="document.TestForm.TestField.focus()">
<form name="TestForm">
Field: <input name="TestField" size="40">


<body onload="document.TestForm.TestField.focus()">
<applet code="TestApplet.class" width="2" height="2" style="display:none"></applet> <form name="TestForm">
Field: <input name="TestField" size="40">


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

There are a couple of options here:
(1) Use Netscape instead of MSIE.
(2) In the onload code, use setTimeout() to reset the focus after a few hundred milliseconds. This gives the applet time to steal the focus, then we can steal it back.
(Incident Review ID: 218432) 
###@###.### 10/13/04 10:09 GMT

EVALUATION This bug has been fixed in the new plugin. Verified that this bug is not reproducible with 6u10 b21 in IE.

EVALUATION Besides the work done in update release and the fix for 6234219, there are no plans to implement another beheavior in Mustang. This still remains an important bug and we'll look into the alternative solutions for it in Dolphin.

CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mustang

EVALUATION Talked to Deva. It is very complicated issue. 1. Applet over aggressively grabs focus. 2. Asynchronized focus handle between applet and plugin control window. ###@###.### 2004-01-29 Since setDefaultFocus() method, which is the place to grab focus not matter browser grants focus to applet or not, was developed by AWT team, it is better to have AWT team to do further investigation and fix. One thing I would like to point out. display:none is not the only case causes applet not getting default focus. There is potential unlimited way to not make applet as default focus component, by html tag attributes, tabIndex or javascript. So, fix should not base on special cases. Re-assign to AWT team. ###@###.### 2004-02-09