classpath-patches
[Top][All Lists]
Advanced

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

[cp-patches] FYI: fixed javax.swing.SwingUtilities methods


From: Roman Kennke
Subject: [cp-patches] FYI: fixed javax.swing.SwingUtilities methods
Date: Thu, 19 May 2005 14:39:35 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021204

I fixed the getUIInputMap() and getUIActionMap() methods in javax.swing.SwingUtilities. Thanks to Micheal for pointing me in the right direction with this.

2005-05-19  Roman Kennke  <address@hidden>

       * javax/swing/SwingUtilities.java
       (getUIInputMap): Return the InputMap that has been set by
       the UI of the component, not the component's own InputMap.
       (getUIActionMap): Return the ActionMap that has been set by
       the UI of the component, not the component's own ActionMap.

/Roman

Index: javax/swing/SwingUtilities.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/SwingUtilities.java,v
retrieving revision 1.24
diff -u -r1.24 SwingUtilities.java
--- javax/swing/SwingUtilities.java     18 May 2005 08:31:31 -0000      1.24
+++ javax/swing/SwingUtilities.java     19 May 2005 12:35:34 -0000
@@ -1335,7 +1335,13 @@
    */
   public static InputMap getUIInputMap(JComponent component, int cond)
   {
-    return component.getInputMap(cond);
+    if (UIManager.getUI(component) != null)
+      // we assume here that the UI class sets the parent of the component's
+      // InputMap, which is the correct behaviour. If it's not, then
+      // this can be considered a bug
+      return component.getInputMap(cond).getParent();
+    else
+      return null;
   }
 
   /**
@@ -1344,8 +1350,14 @@
    *
    * @param component the component for which the ActionMap is returned
    */
-  public static InputMap getUIActionMap(JComponent component)
+  public static ActionMap getUIActionMap(JComponent component)
   {
-    return component.getInputMap();
+    if (UIManager.getUI(component) != null)
+      // we assume here that the UI class sets the parent of the component's
+      // ActionMap, which is the correct behaviour. If it's not, then
+      // this can be considered a bug
+      return component.getActionMap().getParent();
+    else
+      return null;
   }
 }

reply via email to

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