JDK-6502358 : REG: Iconifying and restoring the frame programmatically takes the focus off the initial component
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2006-12-08
  • Updated: 2011-03-07
  • Resolved: 2011-03-07
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 :  
Relates :  
Description
Actually this defect was in SolSparc10-JDS and SuSE10 and it was working fine in windows 
so this bug (6480534) is fixed in jdk7.0 b04
The fix is breaking same functionality in windows.

Reproduce the defect only  in Window:  I reproduced this defect in windows home edition
------------------------------------
Iconifying the frame programmatically by calling frame.setExtendedState(ICONIFIED) and then restoring it with a subsequent call to setExtendedState(NORMAL) removes the focus from the initial component on the frame. In my app, I have added a button to the frame and I am calling the above methods when the button is clicked. When the frame gets restored, the button no longer has the focus and window is also not activated. 

I have attached a sample test. Run the test. A frame would appear with a button. Click on the button and wait for sometime. Frame would iconify and restore. When the frame comes back, check if button has the focus. If not, the bug is reproduced.

Comments
SUGGESTED FIX +++ awt_Component.cpp 2007-02-22 15:39:46.000000000 +0300 @@ -2206,16 +2206,18 @@ if (sm_focusOwner == hwnd) { return TRUE; } HWND fgWindow = ::GetForegroundWindow(); - DWORD fgProcessID; - ::GetWindowThreadProcessId(fgWindow, &fgProcessID); + if (NULL != fgWindow) { + DWORD fgProcessID; + ::GetWindowThreadProcessId(fgWindow, &fgProcessID); - if (fgProcessID != ::GetCurrentProcessId()) { - // fix for 6458497. we shouldn't request focus if it is out of our application. - return FALSE; + if (fgProcessID != ::GetCurrentProcessId()) { + // fix for 6458497. we shouldn't request focus if it is out of our application. + return FALSE; + } } AwtFrame *owner = GetContainer()->GetOwningFrameOrDialog(); if (owner == NULL) {
26-02-2007

EVALUATION the problem is that fix for 6458497 doesn't handle correctly the case when current foreground window is null. In this case, I believe, we should allow request.
26-02-2007

EVALUATION The bug is a regression of the fix for 6458497, that prevents Java from requesting focus if it went out of the application.
26-01-2007

EVALUATION It failed in dolphin b03.
16-01-2007