classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] FYI: JComponent WHEN_ANCESTOR_OF_FOCUSED_COMPONENT implemen


From: Anthony Balkissoon
Subject: [cp-patches] FYI: JComponent WHEN_ANCESTOR_OF_FOCUSED_COMPONENT implemented
Date: Mon, 15 Aug 2005 15:57:14 -0400

This patch implements some of the missing functionality for handling key
events.  Without this patch, key events only work for the focused
component.  This patch allows focused components that receive a key
event but don't use it to pass it up the containment hierarchy and see
if any of its ancestors registered that key with the
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT flag.

There is also a much lesser used flag, WHEN_IN_FOCUSED_WINDOW, and I
haven't yet implemented this code but I will try to do so in the next
few days.

This patch can be tested using the Swing demo through the JTable widget.
Pressing F2 allows you to edit a cell and gives focus to a JTextField.
However, key strokes such as PAGE UP or ESCAPE which are not consumed by
the JTextField get passed to the parent JTable and are used, in this
case to scroll up in the table or to stop editing the cell.

The patch is attached.

2005-08-15  Anthony Balkissoon  <address@hidden>

* javax/swing/JComponent.java:
(processKeyEvent): Added functionality for processing key events in
non-focused components using the WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
field.
* javax/swing/plaf/basic/BasicTableUI.java:
(installKeyboardActions): Changed key bindings to be registered as
WHEN_ANCESTOR_OF_FOCUSED_COMPONENT rather than as WHEN_FOCUSED.
(TableAction.actionPerformed): If the key action is anything besides
"start editing" then we stop editing if we are doing so.  Repaint the
table at the end of this method.


-Tony

Attachment: JComponentWHEN_ANCESTOR.diff
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]