Relates :
|
|
Relates :
|
|
Relates :
|
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>
|