classpath-patches
[Top][All Lists]
Advanced

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

Re: [cp-patches] FYI: added methods to javax.swing.SwingUtilities


From: Michael Koch
Subject: Re: [cp-patches] FYI: added methods to javax.swing.SwingUtilities
Date: Thu, 19 May 2005 08:14:13 +0200
User-agent: mutt-ng 1.5.9-r292i (Debian)

On Wed, May 18, 2005 at 10:29:42AM +0200, Roman Kennke wrote:
> I added 2 methods to javax.swing.SwingUtilities:
> 
> 2005-05-18  Roman Kennke  <address@hidden>
> 
>         * javax/swing/SwingUtilities
>         (getUIInputMap): Added method.
>         (getUIActionMap): Added method.
> 
> 
> /Roman
> 

> Index: javax/swing/SwingUtilities.java
> ===================================================================
> RCS file: /cvsroot/classpath/classpath/javax/swing/SwingUtilities.java,v
> retrieving revision 1.23
> diff -u -r1.23 SwingUtilities.java
> --- javax/swing/SwingUtilities.java   12 Feb 2005 14:26:02 -0000      1.23
> +++ javax/swing/SwingUtilities.java   18 May 2005 08:27:47 -0000
> @@ -1319,4 +1319,33 @@
>             && b.x >= a.x && b.x + b.width <= a.x + a.width && b.y >= a.y
>             && b.y + b.height <= a.y + a.height;
>    }
> +
> +  /**
> +   * Returns the InputMap that is provided by the ComponentUI of
> +   * <code>component</code> for the specified condition.
> +   *
> +   * @param component the component for which the InputMap is returned
> +   * @param cond the condition that specifies which of the three input
> +   *     maps should be returned, may be
> +   *     address@hidden JComponent#WHEN_IN_FOCUSED_WINDOW},
> +   *     address@hidden JComponent#WHEN_FOCUSED} or
> +   *     address@hidden JComponent#WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
> +   *
> +   * @return
> +   */
> +  public static InputMap getUIInputMap(JComponent component, int cond)
> +  {
> +    return component.getInputMap(cond);
> +  }
> +
> +  /**
> +   * Returns the ActionMap that is provided by the ComponentUI of
> +   * <code>component</code>.
> +   *
> +   * @param component the component for which the ActionMap is returned
> +   */
> +  public static InputMap getUIActionMap(JComponent component)
> +  {
> +    return component.getInputMap();
> +  }
>  }

After reading a bit in the javadocs and several places on the net this is wrong.
Each component is considered to have its own ActionMap and InputMap with the
according map of the ComponentUI as parent. AFAIK the correct code would to
check if a ComponentUI is associated with the compenent and then return the 
parent
of the ActionMap/InputMap.


Michael
-- 
Escape the Java Trap with GNU Classpath!
http://www.gnu.org/philosophy/java-trap.html

Join the community at http://planet.classpath.org/




reply via email to

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