JDK-4027897 : Solaris: Labels & Scrollbars can't receive focus events
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.1
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_2.5.1
  • CPU: sparc
  • Submitted: 1997-01-24
  • Updated: 2002-06-17
  • Resolved: 2002-04-04
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.
Other
1.4.1 hopperFixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
Labels and Scrollbars can't receive focus events, and therefore can't 
receive KeyEvents.

Try:
 appletviewer /home/jeff/applets/Events/stable/listener1.html

Works on win32

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: hopper FIXED IN: hopper INTEGRATED IN: hopper VERIFIED IN: hopper-beta
14-06-2004

EVALUATION Used following test case to see if scrollbar can receive key event: import java.awt.*; import java.awt.event.*; public class test extends Frame implements AdjustmentListener { public static void main(String argv[]) { test t = new test(); t.show(); t.setSize(20,60); } class myKeyEvent extends KeyAdapter { public void keyPressed(KeyEvent e) { System.out.println("Key in scrollbar = "+e.getKeyChar()); } } public test() { // Scrollbar sb = new Scrollbar(Scrollbar.HORIZONTAL,0,10,0,100); Scrollbar sb = new Scrollbar(Scrollbar.VERTICAL,0,1,-2,2); add("West", sb); sb.addAdjustmentListener(this); sb.addKeyListener(new myKeyEvent()); Label l = new Label("This is a label"); add("North", l); l.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { System.out.println("Key in lable = "+e.getKeyChar()); } }); } public void adjustmentValueChanged(AdjustmentEvent e) { System.out.println("Value="+e.getValue()); } } On Win32 and Solaris, scrollbar is consistently key event receivalbe. But Label has different behavior, it cannot receive key event on Win32. xianfa.deng@Eng 1997-11-25 ============================================================================ Tested on WinNT 4.0 SP5 using JDK 1.3RA and the bug was reproducible. sandeep.konchady@Eng 1999-11-24 Name: dmR10075 Date: 02/04/2002 Hopper situation: On Solaris we treat ScrollBar and Label as focusable by mouse, while on Windows we don't do this. Documentation doesn't clarify this. I think that ScrollBar (alone) should be treated focusable, (non-focusable only if requested), while label should be treated focusable only if requested. ###@###.### 2002-02-04 ====================================================================== Name: dmR10075 Date: 03/15/2002 The bug can be verified using the test from the report and the regression test test/java/awt/Focus/LabelScrollbar/LabelScrollbarFocus.* ###@###.### 2002-03-15 ======================================================================
15-03-2002

SUGGESTED FIX Name: dmR10075 Date: 03/06/2002 *** /cygdrive/n/TEMP\geta868 Fri Mar 1 14:04:24 2002 --- awt_Scrollbar.cpp Fri Mar 1 14:02:07 2002 *************** *** 9,14 **** --- 9,15 ---- #include "awt_Scrollbar.h" #include "awt_Canvas.h" + #include "awt_KeyboardFocusManager.h" /* IMPORTANT! Read the README.JNI file for notes on JNI converted AWT code. */ *************** *** 162,167 **** --- 163,178 ---- AwtScrollbar::HandleEvent(MSG *msg, BOOL synthetic) { if (msg->message == WM_LBUTTONDOWN || msg->message == WM_LBUTTONDBLCLK) { + if (AwtComponent::sm_focusOwner != GetHWnd()) { + JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); + jobject target = GetTarget(env); + env->CallStaticVoidMethod + (AwtKeyboardFocusManager::keyboardFocusManagerCls, + AwtKeyboardFocusManager::heavyweightButtonDownMID, + target, ((jlong)msg->time) & 0xFFFFFFFF); + env->DeleteLocalRef(target); + AwtSetFocus(); + } // Left button press was already routed to default window // procedure in the WmMouseDown above. Propagating synthetic // press seems like a bad idea as internal message loop *** /tmp/geta2291 Fri Mar 1 14:35:36 2002 --- awt_TopLevel.c Fri Mar 1 14:33:32 2002 *************** *** 987,992 **** --- 987,995 ---- XtVaGetValues(w, XmNnumChildren, &count, NULL); return (count > 0)?(False):(True); } + if (XmIsLabel(w)) { + return False; + } return True; } ###@###.### 2002-03-06 ======================================================================
06-03-2002