[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cp-patches] Patch (Suggestions Needed): JComponent key bindings
From: |
Anthony Balkissoon |
Subject: |
[cp-patches] Patch (Suggestions Needed): JComponent key bindings |
Date: |
Wed, 09 Nov 2005 17:10:19 -0500 |
This patch implements the package-private class
javax.swing.KeyboardManager and makes some adjustments in JComponent to
allow keybindings registered with the condition WHEN_IN_FOCUSED_WINDOW
to work.
This mechanism is not 100% correct yet. Attached is a test case that
works. Click on the JButton to give it focus. Then pressing 'a' prints
"I'm Focused" to the screen. Clicking on the JCheckBox gives it focus
(so the JButton is not focused) and then pressing 'a' prints "I'm In
Focused Window" to the screen ==> this is new functionality, the JButton
can register key bindings that work even when it is not focused or an
ancestor of the focused component, it's just in the focused window.
However, if, in the testcase, the keybinding is registered before the
JButton is added to the JFrame (its top-level ancestor), our
implementation fails. This is because when the key action is bound the
JButton had no top-level ancestor, and when the JButton was added to the
JFrame it doesn't re-hash its bindings.
So, I have to find a way to re-hash WHEN_IN_FOCUSED_WINDOW bindings when
components are added to containers. Unfortunately, adding occurs in
Containers in AWT and much of the needed code is in package-private
methods or classes in Swing. For instance, to re-hash bindings I need
to use the KeyboardManager class, or at least the method
JComponent.updateComponentInputMap. Anyone have any suggestions?
2005-11-09 Anthony Balkissoon <address@hidden>
* javax/swing/JComponent.java:
(processKeyEvent): Use local variables for boolean pressed and for
the KeyStroke. Implemented the code for WHEN_IN_FOCUSED_WINDOW
bindings.
(updateComponentInputMap): Implemented and fixed typo in docs.
* javax/swing/KeyboardManager.java: New class.
WHEN_IN_FOCUSED_WINDOW2.diff
Description: Text Data
Test.java
Description: Text Data
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [cp-patches] Patch (Suggestions Needed): JComponent key bindings,
Anthony Balkissoon <=