JDK-6538154 : requesting focus on applet doesn't bring the browser to front
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2007-03-23
  • Updated: 2011-05-18
  • Resolved: 2011-05-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.
JDK 7
7 b14Fixed
Related Reports
Relates :  
Description
PLATFORM:

Windows, IE, JRE 7.0

PROBLEM:

There're two IE windows opened, belonging to the same process.
At the first window there is an applet with a focusable component inside,
at the second window there is a JavaScript that triggers focus request
on the applet. When the second IE window is active requesting focus
doesn't success:

- the applet's component is repainted as it would have focus
- tabbing yet moves focus in the second IE frame
- the second IE frame still remains the foreground window.

HOW TO REPRODUCE:

1. Download attached files: testie.html, testchild.html and TestApplet.java
2. Compile TestApplet.java
3. Change "CODEBASE VALUE" parameter in the testie.html to appropriate value
4. Run the testie.html in the IE browser
5. Click "Open child" button (the second IE window will appear)
6. Click "Focus Applet" in the second IE window

Expected behavior:
  The first IE window will bring to front and the applet's button will gain focus.

Actual behavior:
  The second IE window remains active and keeps focus in it.

Comments
SUGGESTED FIX Find the webrev here: http://javaweb.sfbay/jcg/7/awt/6538154
14-04-2007

EVALUATION In addition to the said above. It's principal what window is active at the time the request is performed. The active window should belong to the same process, but be of a different thread. It doesn't matter from which thread the focus is requested. The request procedure (setting focus via ::SetFocus()) will anyway be passed to the toolkit. What if the active window belongs to a different process? In this case AWT will reject setting native focus (see AwtComponent::AwtSetFocus). When the active window is of the same thread, MS Windows normally switches the foreground window.
02-04-2007

EVALUATION Worth to say that the problem is seen only when focus is requested to the applet from the window of another thread (like in the testcase). If we would show a Java window from the applet and then activate it and request focus back in the applet it will work fine. The reason of this difference in native behavior is not clear...
30-03-2007

EVALUATION Looks like we should set the IE the foreground window when receiving WM_SETFOCUS in the applet.
23-03-2007

EVALUATION Originally the problem was reported in the CR 6523707 against 5.0u6, 5.0u10.
23-03-2007