United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-4985406 REG:Window components does not receive key events even when they have focus
JDK-4985406 : REG:Window components does not receive key events even when they have focus

Details
Type:
Bug
Submit Date:
2004-01-29
Status:
Closed
Updated Date:
2005-12-01
Project Name:
JDK
Resolved Date:
2005-09-07
Component:
client-libs
OS:
windows_xp
Sub-Component:
java.awt
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
6
Fixed Versions:

Related Reports
Relates:
Relates:

Sub Tasks

Description
I am creating a frame & a window and making this frame as the parent of the window. Frame and Window contain a button component each. I have added the focus listener to the components and window focus listeners to the window and frame. When the application launches, the focus is given to the button on the window. This button is supposed to dispose the window itself when clicked. On Win32, when I press space bar, no action event is triggered by the button on the window. On the console, the respective focus listeners show that this button is having focus and this window is the focused window. I am able to see the button being pressed visually when I press space bar and somehow, the key event is not getting delivered to the component. When I click the button with the mouse, it works fine.

This is noticed only from 1.4.2 on win32 alone and this application works fine on other platforms. I am able to reproduce this with Tiger-beta2-b35. I tested this with Win XP Pro.

I have attached a sample test. Execute the test. You would see a window and a frame on the screen, each of them having a button. Check whether the focus is in 'Dispose' button on the window. If not, click the 'Show' button on the frame. Once Dispose gains focus, press the space bar. If you notice the button being visually pressed and if the window still remains, the bug is reproduced.  

                                    

Comments
SUGGESTED FIX

Name: osR10079			Date: 01/29/2004


------- awt_Frame.cpp -------
*** /tmp/sccs.ImaqLy	Fri Jan 30 09:18:07 2004
--- awt_Frame.cpp	Fri Jan 30 09:17:55 2004
***************
*** 298,303 ****
--- 298,307 ----
          case WM_IME_KEYUP:
          case WM_INPUTLANGCHANGEREQUEST:
          case WM_INPUTLANGCHANGE:
+         case WM_SYSKEYUP:
+         case WM_KEYUP:
+         case WM_KEYDOWN:
+         case WM_SYSKEYDOWN:
              AwtComponent *p = AwtComponent::GetComponent(sm_focusOwner);
              if  (p!= NULL) {
                  return p->WindowProc(message, wParam, lParam);
###@###.###  Jan 30, 2004

======================================================================

See the suggested fix for the bug 5087251.
                                     
2004-08-18
EVALUATION

Name: osR10079			Date: 01/29/2004

This is regression from fix for 4712880&4759722 (delta 1.121)
In this fix ProxyWindowProc() starts retarget all IME related events to
sm_focusOwner, but it doesn't retarget WM_[SYS]KEY(UP|DOWN) events.
Thus button doesn't receive WM_KEYUP to generate ActionEvent.
To fix the problem we should also retarget all key-related events to
sm_focusOwner too.
###@###.###  Jan 30, 2004
======================================================================

I have tried to reproduce this bug using the attached test case:
- On Windows this bug is not reproducible any more. See 5087251 (integrated in build 45). The cause is that the list component is not native focus owner. In fix for 5087251 some processing was moved on Java level so it's not reproducible any more. About the retargeting all key-related events: the only special native processing by the button component is VK_SPACE processing so it's enough to move this processing to Java level. 
- On XAWT the focus is not transfered to the 'Dispose' button. The similar bug is the bug 6253919. Will not be investigated here.
- On Motif it works fine.
                                     
2004-08-18
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
mustang


                                     
2004-08-18



Hardware and Software, Engineered to Work Together