classpath-patches
[Top][All Lists]
Advanced

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

[cp-patches] FYI: JTable InputMap - ActionMap pairs implemented


From: Tony Balkissoon
Subject: [cp-patches] FYI: JTable InputMap - ActionMap pairs implemented
Date: Fri, 12 Aug 2005 16:49:39 -0400

This patch properly implements key bindings for JTable.  This involved
creating InputMap-ActionMap pairs rather than using low level Key
Listeners.  This way JTable can respond to events even when it is not
the focused component (ie - when a cell is being edited, the JTextField
is the focused component, but keys like PAGE_UP still need to work in
the JTable) through the facilities of adding to the JTable's InputMap
with the flag JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT.

Note that currently the keyboard manager isn't properly handling these
flags, so I have used the default InputMap (corresponding to
JComponent.WHEN_FOCUSED) but I will investigate this and make the
changes very shortly.

The patch is quite large and unpleasant to read, I think because chunks
of code were moved from the top to the bottom of the file, so the
ChangeLog entry is best for explaining what changes were made.

Patch is attached.

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

* javax/swing/JTable.java:
(setValueAt): Do nothing if isCellEditable returns false.
(editCelLAt): Removed the Key Listener for the JTextField.  Listening
for ESCAPE should be handled by the JTable itself.  Note, this is not
implemented yet.
* javax/swing/plaf/basic/BasicLookAndFeel.java:
(initComponentDefaults): Added several keybindings to JTable's
ancestorInputMap.  These are all implemented.
* javax/swing/plaf/basic/BasicTableUI.java:
(KeyHandler): Removed this class.  Note that most of the code from the
keyPressed method now resides in the actionPerformed method of the
BasicTableUI.TableAction class.
(convertModifiers): New private method to convert from new InputEvent
modifier masks to the old style.
(installKeyboardActions): Implemented.  Gets the key bindings from
the UIManager and registers them for the JTable.
(TableAction): New class.  This is where the actions corresponding to
key presses resides.
(installListeners): Removed installation of KeyListener.

- Tony

Attachment: JTableProperKeyInstallation.diff
Description: Text Data


reply via email to

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