jdk/src/share/classes/javax/swing/plaf/basic/LazyActionMap.java
changeset 25565 ce603b34c98d
parent 23697 e556a715949f
equal deleted inserted replaced
25564:871d3490f14d 25565:ce603b34c98d
    54      * @param loaderClass Class object that gets loadActionMap invoked
    54      * @param loaderClass Class object that gets loadActionMap invoked
    55      *                    on.
    55      *                    on.
    56      * @param defaultsKey Key to use to defaults table to check for
    56      * @param defaultsKey Key to use to defaults table to check for
    57      *        existing map and what resulting Map will be registered on.
    57      *        existing map and what resulting Map will be registered on.
    58      */
    58      */
    59     static void installLazyActionMap(JComponent c, Class loaderClass,
    59     static void installLazyActionMap(JComponent c, Class<?> loaderClass,
    60                                      String defaultsKey) {
    60                                      String defaultsKey) {
    61         ActionMap map = (ActionMap)UIManager.get(defaultsKey);
    61         ActionMap map = (ActionMap)UIManager.get(defaultsKey);
    62         if (map == null) {
    62         if (map == null) {
    63             map = new LazyActionMap(loaderClass);
    63             map = new LazyActionMap(loaderClass);
    64             UIManager.getLookAndFeelDefaults().put(defaultsKey, map);
    64             UIManager.getLookAndFeelDefaults().put(defaultsKey, map);
    77      * @param loaderClass Class object that gets loadActionMap invoked
    77      * @param loaderClass Class object that gets loadActionMap invoked
    78      *                    on.
    78      *                    on.
    79      * @param defaultsKey Key to use to defaults table to check for
    79      * @param defaultsKey Key to use to defaults table to check for
    80      *        existing map and what resulting Map will be registered on.
    80      *        existing map and what resulting Map will be registered on.
    81      */
    81      */
    82     static ActionMap getActionMap(Class loaderClass,
    82     static ActionMap getActionMap(Class<?> loaderClass,
    83                                   String defaultsKey) {
    83                                   String defaultsKey) {
    84         ActionMap map = (ActionMap)UIManager.get(defaultsKey);
    84         ActionMap map = (ActionMap)UIManager.get(defaultsKey);
    85         if (map == null) {
    85         if (map == null) {
    86             map = new LazyActionMap(loaderClass);
    86             map = new LazyActionMap(loaderClass);
    87             UIManager.getLookAndFeelDefaults().put(defaultsKey, map);
    87             UIManager.getLookAndFeelDefaults().put(defaultsKey, map);
    88         }
    88         }
    89         return map;
    89         return map;
    90     }
    90     }
    91 
    91 
    92 
    92 
    93     private LazyActionMap(Class loader) {
    93     private LazyActionMap(Class<?> loader) {
    94         _loader = loader;
    94         _loader = loader;
    95     }
    95     }
    96 
    96 
    97     public void put(Action action) {
    97     public void put(Action action) {
    98         put(action.getValue(Action.NAME), action);
    98         put(action.getValue(Action.NAME), action);
   144 
   144 
   145             _loader = null;
   145             _loader = null;
   146             Class<?> klass = (Class<?>)loader;
   146             Class<?> klass = (Class<?>)loader;
   147             try {
   147             try {
   148                 Method method = klass.getDeclaredMethod("loadActionMap",
   148                 Method method = klass.getDeclaredMethod("loadActionMap",
   149                                       new Class[] { LazyActionMap.class });
   149                                       new Class<?>[] { LazyActionMap.class });
   150                 method.invoke(klass, new Object[] { this });
   150                 method.invoke(klass, new Object[] { this });
   151             } catch (NoSuchMethodException nsme) {
   151             } catch (NoSuchMethodException nsme) {
   152                 assert false : "LazyActionMap unable to load actions " +
   152                 assert false : "LazyActionMap unable to load actions " +
   153                         klass;
   153                         klass;
   154             } catch (IllegalAccessException iae) {
   154             } catch (IllegalAccessException iae) {