JDK-4736354 : RFE: Can't stop MenuKeyboardHelper from giving JRootPane focus
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.0
  • Priority: P5
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_nt
  • CPU: x86
  • Submitted: 2002-08-23
  • Updated: 2002-08-23
  • Resolved: 2002-08-23
Related Reports
Duplicate :  
Description

Name: jk109818			Date: 08/23/2002


FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

FULL OPERATING SYSTEM VERSION :
Windows NT Version 4.0

A DESCRIPTION OF THE PROBLEM :
I have a component 'DatePanel' that is a JPanel with a
JTextField and a JButton, and when you press the JButton it
pops up a component 'CalendarPopup' which extends
JPopupMenu. Using JComboBox as a guideline, I made both the
JButton and CalendarPopup unable to gain focus (ie;
isFocusTraversable() returns false) so the cursor remains
in the JTextField when CalendarPopup is shown. Similar to
JComboBox, I install some Actions on the JTextField (which
allow you to navigate the CalendarPopup using the
keyboard). This worked fine in JDK1.3 but with JDK1.4's new
focus system the JRootPane gains focus whenever
CalendarPopup is shown. This is a problem because now the
Actions installed on the JTextField don't work, and its
visually confusing because the Caret has disappeared from
the JTextField. I tracked the problem down to
BasicPopupMenuUI line 816 (the stateChanged() method of the
MenuKeyboardHelper inner class). If the popup is an
instance of BasicComboPopup then MenuKeyboardHelper doesn't
transfer focus to the JRootPane, but it does for all other
types of PopupMenus (including my CalendarPopup). It would
be really great if you could make MenuKeyboardHelper
protected (rather than private) and instantiate it in a
helper method (rather than directly in
BasicPopupMenuUI.installListeners()) so I can extend it and
override stateChanged() to not transfer focus when my
CalendarPopup is shown. Alternatively you could provide a
method in the JPopupMenu class which lets programmers set
whether their popups should cause focus to go to the
JRootPane.


REGRESSION.  Last worked in version 1.3.1

This bug can be reproduced always.
(Review ID: 146652) 
======================================================================

Comments
EVALUATION This has been fixed by 4632782 in 1.4.1, if you make the JPopupMenu unfocusable (setFocusable(false)) focus will not move to the JRootPane. ###@###.### 2002-08-23
23-08-2002