Hi list, I have found the bugs that prevented the WHEN_IN_FOCUSED_WINDOW inputmap from working correctly. Attached you find the patch that finally enables the default button:
2006-03-25 Roman Kennke <[EMAIL PROTECTED]>
* javax/swing/InputMap.java
(allKeys): Check if parent keys is null.
* javax/swing/KeyboardManager.java
(registerEntireMap): Also register map's parent keys.
* javax/swing/plaf/metal/MetalRootPaneUI.java
(propertyChange): Also call super.propertyChange().
/Roman
--
“Improvement makes straight roads, but the crooked roads, without
Improvement, are roads of Genius.” - William Blake
Index: javax/swing/InputMap.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/InputMap.java,v
retrieving revision 1.13
diff -u -1 -0 -r1.13 InputMap.java
--- javax/swing/InputMap.java 14 Nov 2005 20:23:56 -0000 1.13
+++ javax/swing/InputMap.java 25 Mar 2006 18:22:30 -0000
@@ -183,22 +183,25 @@
* Returns all keys of entries in this <code>InputMap</code>
* and all its parents.
*
* @return an array of keys
*/
public KeyStroke[] allKeys()
{
Set set = new HashSet();
if (parent != null)
- set.addAll(Arrays.asList(parent.allKeys()));
-
+ {
+ Object[] parentKeys = parent.allKeys();
+ if (parentKeys != null)
+ set.addAll(Arrays.asList(parentKeys));
+ }
set.addAll(inputMap.keySet());
if (set.size() == 0)
return null;
KeyStroke[] array = new KeyStroke[set.size()];
return (KeyStroke[]) set.toArray(array);
}
/**
* writeObject
*
Index: javax/swing/KeyboardManager.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/KeyboardManager.java,v
retrieving revision 1.5
diff -u -1 -0 -r1.5 KeyboardManager.java
--- javax/swing/KeyboardManager.java 16 Nov 2005 18:58:51 -0000 1.5
+++ javax/swing/KeyboardManager.java 25 Mar 2006 18:22:30 -0000
@@ -188,21 +188,21 @@
* so that we don't duplicate finding the top-level container and
* getting its Hashtable.
*
* @param map the ComponentInputMap whose bindings we want to register
*/
public void registerEntireMap (ComponentInputMap map)
{
if (map == null)
return;
JComponent comp = map.getComponent();
- KeyStroke[] keys = map.keys();
+ KeyStroke[] keys = map.allKeys();
if (keys == null)
return;
// Find the top-level container associated with this ComponentInputMap
Container topLevel = findTopLevel(comp);
if (topLevel == null)
return;
// Register the KeyStrokes in the top-level container's Hashtable
Hashtable keyToComponent = getHashtableForTopLevel(topLevel);
for (int i = 0; i < keys.length; i++)
Index: javax/swing/plaf/metal/MetalRootPaneUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalRootPaneUI.java,v
retrieving revision 1.4
diff -u -1 -0 -r1.4 MetalRootPaneUI.java
--- javax/swing/plaf/metal/MetalRootPaneUI.java 30 Jan 2006 15:32:21 -0000 1.4
+++ javax/swing/plaf/metal/MetalRootPaneUI.java 25 Mar 2006 18:22:30 -0000
@@ -930,20 +930,21 @@
/**
* Receives notification if any of the JRootPane's property changes. In
* particular this catches changes to the <code>windowDecorationStyle</code>
* property and installs the window decorations accordingly.
*
* @param ev the property change event
*/
public void propertyChange(PropertyChangeEvent ev)
{
+ super.propertyChange(ev);
String propertyName = ev.getPropertyName();
if (propertyName.equals("windowDecorationStyle"))
{
JRootPane rp = (JRootPane) ev.getSource();
if (rp.getWindowDecorationStyle() != JRootPane.NONE)
installWindowDecorations(rp);
else
uninstallWindowDecorations(rp);
}
}
signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil
