United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6332100 : Focus lost in Textfield after doing a back/forward from Internet Explorer using

Details
Type:
Bug
Submit Date:
2005-10-04
Status:
Resolved
Updated Date:
2011-02-16
Project Name:
JDK
Resolved Date:
2006-04-11
Component:
deploy
OS:
windows_2000
Sub-Component:
plugin
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
1.4.2_10
Fixed Versions:
1.4.2_12 (b02)

Related Reports
Relates:

Sub Tasks

Description
Using the following file(s):

   appletTextFieldCursor.html (note: 'legacy_lifecycle=true')
   TextFieldCursor.java

On Windows 2000, run the testcase with the jre 1.4.2_07 plugin via IE.          1)Launch IE where a webpage (www.javasoft.com) is displayed.
2)Then open the appletTextFieldCursor.html by using File->Open.
3)When the testcase appears you'll see a Form with a single non-navigable JButton() and a JTextField() with "555" highlighted.  4)Now, use the IE browsers back button and forward button until you see the JTextField() looses focus. We have found that this testcase does not reproduce on Windows XP.

JDK/JRE tested with:
   1.4.2_07/08/09
   1.5.2_04


<html>
<head>
  <title>TextFieldCursor (Oracle)</title>
</head>
<body>
<object classid="clsid:CAFEEFAC-0014-0002-0008-ABCDEFFEDCBA"
        WIDTH="400" HEIGHT="300">
<param name="TYPE"     value="application/x-java-applet;jpi-version=1.4.2_08">
<param name="IE"       value="native" >
<param name="legacy_lifecycle" value="true" >
<param name="CODE"     value="TextFieldCursor" >
</object>
</body>
</html>



import java.awt.*;
import java.awt.event.*;

import javax.swing.*;

public class TextFieldCursor extends JApplet
                             implements ComponentListener,
                                        ActionListener
{

    JTextField textField;
    JTextArea textArea;
    JButton jButton;

    private boolean          mFocusRequestedForApplet = false;

    public void init()
    {
        textField = new JTextField();
        textField.addActionListener(this);
        jButton = new JButton();

        getContentPane().setLayout(null);
        textField.setText("555");
        textField.setBounds(new Rectangle(100, 40, 150, 30));
        textField.setFont(new Font("Arial", 0, 16));

        jButton.setText("Button");
        jButton.setRequestFocusEnabled(false);
        jButton.setBounds(new Rectangle(130, 75, 90, 30));
        jButton.setToolTipText("");
        getContentPane().add(jButton, null);
        getContentPane().add(textField, null);

        getContentPane().setVisible(true);
        setVisible(true);

        textField.requestFocus();
        textField.selectAll();
    }


    public void actionPerformed(ActionEvent evt)
    {

    }


    public void start()
    {
        addComponentListener(this);
    }


    /**
    ** Stops the Applet.
    **
    ** @see java.applet.Applet
    */
    public void stop()
    {
        removeComponentListener(this);
        mFocusRequestedForApplet = false;
    }


    //------------------------------------------------------------------------
    // ComponentListener Interface
    //------------------------------------------------------------------------
    public void componentResized(ComponentEvent e)
    {

    }


    public void componentMoved(ComponentEvent e)
    {

    }


    public void componentShown(ComponentEvent e)
    {
        textField.requestFocus();
        textField.selectAll();
        mFocusRequestedForApplet = true;
    }


    public void componentHidden(ComponentEvent e)
    {

    }


    public void requestFocus()
    {
        if ( !mFocusRequestedForApplet )
        {
            super.requestFocus();
        }
    }

}

                                    

Comments
EVALUATION

I tried 1.4.2_08 on windows 2000 server and cannot reproduce this bug. I press "back" and "forward" button 10 times. BTW there is no 1.5.2_04, so I just tried 1.5.0_05 from java.sun.com and also cannot reproduce it. 

please provide more info , such as how many times to press "back" and "forward", what's version of windows 2000 ( prefession or server, service pack , etc)

Steps to reproduce this bug:

@ Testcase:
@ 1) Launch IE (javasoft.com) and wait for the website to fully load,
@ 2) Run the testcase,
@ 3) Use the back/forward button - this may take 10- 30 iterations (at most)
@     but usually occurs around 5-15 iterations. Durring my testing, after
@     executing the back button I sometimes waited for all the images to
@     repaint until the forward button was executed.
@ .
@ Also, this testcase demonstrates a loss of focus when you navigate to a
@ window that overlays the testcase.  For example, when running the testcase
@ the java console is launched in the upper left hand corner. The testcase is
@ then displayed over the java console. If you navigate to the java console and
@ it overlays the textfield then navigate back to the testcase you will notice
@ that the textfield has lost focus.
@ .
@ The 1.5 release(s) that were tested (1.5.2 was a typo):
@      jre-1_5_0_04-windows-i586-p.exe
@      jre-1_5_0_05-windows-i586-p.exe
                                     
2005-10-18
EVALUATION

I tried the latest testcase and still cannot reproduce.  As customer also cannot reproduce with window xp,  I guess it may be an issue of Windows OS.  I used windows 2000 prefessional , SP4 with JRE 1.5.0_05 to do testing.
                                     
2005-11-01
SUGGESTED FIX

Adding the InPlaceActivate function call
to the CAxControl of the java plugin seems to resolve
this matter. A relief binary has been sent to the customer
for verification.
                                     
2006-02-08



Hardware and Software, Engineered to Work Together