JDK-6334864 : Focus traversal problem with Java Applet on a html page
  • Type: Bug
  • Component: deploy
  • Sub-Component: plugin
  • Affected Version: 5.0,5.0u5,5.0u6
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris,windows_xp
  • CPU: other,x86,sparc
  • Submitted: 2005-10-10
  • Updated: 2011-01-28
  • Resolved: 2006-03-01
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.0u8Fixed 6 b74Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
OPERATING SYSTEM(S)
Windows XP
FULL JDK VERSION(S):
java version "1.5.0_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05)
Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing)
java version "1.4.2_09"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_09-b05)
Java HotSpot(TM) Client VM (build 1.4.2_09-b05, mixed mode)
DESCRIPTION:
When an object tag is used to embed the java applet in a html file, there is a focus traversal problem in the parent html page. When using the ?TAB? key on the html page, the focus must cycle through all the elements on the browser window including the embedded applet. When the focus moves into the applet, however, the focus only cycles within the applet and does not get out of the applet to the other html elements on that page.
-Steps for re-creation
1. Compile the TestApplet.java.
2. Open the TestApplet.html using in Internet Explorer
3. Once the html page is loaded, press the TAB key. The focus only cycles within the applet and does not get out of the applet to the other html elements on that page.
TestApplet.java:
import java.applet.*;                                                   
import java.awt.*;                                                      
import java.awt.event.*;                                                
import javax.swing.*;                                                   
import javax.swing.event.*;                                             
                                                                        
                                                                        
public class TestApplet extends JApplet
{
 JButton button;
 JTextField field;
 public void init()
 {
      
     // Set the focus traversal policy
     	setFocusTraversalPolicy(new LayoutFocusTraversalPolicy());
	Container parent = this.getParent ();
	while (!(parent instanceof Window) && parent != null)
   	{ 
		parent= parent.getParent (); 
	}
	if (parent != null) 
	{
		parent.setFocusTraversalPolicy (new javax.swing.LayoutFocusTraversalPolicy ());
  	}
      
	button = new JButton("Push Me");
	field = new JTextField("Type Me");
	getContentPane().setLayout(new GridLayout(1,2));
	getContentPane().add(button);
	getContentPane().add(field);
 }
}                                  
TestApplet.html:
<HTML>                                                                  
<HEAD>                                                                
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;                     
charset=windows-1252">                             
<TITLE>                                                        
Test Focus Applet                                                       
</TITLE>                                                             
</HEAD>                                                                 
<BODY>                                                                  
<form>                                                                  
First name:                                                             
<input type="text" name="fname" value="Mickey" />                       
<br />                                                                  
Last name:                                                              
<input type="text" name="lname" value="Mouse" />                        
<br />                                                                  
<input type="submit" value="Submit" />                                  
</form>                                                                 
Applet                                                                  
<comment> <applet code="TestApplet.class" codebase="." width="850"      
height="500"></applet> </comment>                                       
<form>                                                                  
Address:                                                                
<input type="text" name="address" value="San Jose" />                   
<br />                                                                  
<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" width="50%" height="50%" tabindex="1" name="cmpm-1"
codebase="http://java.sun.com/products/plugin/1.4/jinstall-14-win32.cab#Version=1,4,0,0">
  <param name=CODE            value="TestApplet.class" >
  <param name=NAME            value="TestApplet" >
  <param name=CODEBASE        value="./">
  <param name="type"          value="application/x-java-applet;version=1.4">
  <param name="scriptable"    value="false">
  <param name="IMG"           value="img01.gif">
  <comment> <embed  type="application/x-java-applet;version=1.4"        
                            code="TestApplet.class"                     
                            name="TestApplet"                           
                            codebase="./"                               
                            width="100%" height="100%"                  
                            img="img01.gif"                             
                            scriptable=false                            
                                                                        
pluginspage="http://java.sun.com/products/plugin/1.4/plugin-install.html">                                                    
<noembed> </noembed>
</embed> </comment>
</object>
Country:
<input type="text" name="country" value="USA" />
<br />
<input type="submit" value="California?" />
</form>
</BODY>
</HTML>

Comments
EVALUATION This problem was resolved in the context of RFE 4930813 "Need a way to traverse focus out of EmbeddedFrame". However, the API provided by AWT was used by plugin only for AxBridge. Seems like the API may also be implemented for browsers. Probably for the purpose of backward compatibility deploy team may introduce some property in the applet tag that would allow to switch this functionality on.
02-02-2006