src/java.desktop/share/classes/javax/swing/LookAndFeel.java

Print this page




 329      * @see InputMap
 330      * @see KeyStroke#getKeyStroke
 331      */
 332     public static JTextComponent.KeyBinding[] makeKeyBindings(Object[] keyBindingList)
 333     {
 334         JTextComponent.KeyBinding[] rv = new JTextComponent.KeyBinding[keyBindingList.length / 2];
 335 
 336         for(int i = 0; i < rv.length; i ++) {
 337             Object o = keyBindingList[2 * i];
 338             KeyStroke keystroke = (o instanceof KeyStroke)
 339                 ? (KeyStroke) o
 340                 : KeyStroke.getKeyStroke((String) o);
 341             String action = (String) keyBindingList[2 * i + 1];
 342             rv[i] = new JTextComponent.KeyBinding(keystroke, action);
 343         }
 344 
 345         return rv;
 346     }
 347 
 348     /**
 349      * Creates a {@code InputMapUIResource} from <code>keys</code>. This is
 350      * a convenience method for creating a new {@code InputMapUIResource},
 351      * invoking {@code loadKeyBindings(map, keys)}, and returning the
 352      * {@code InputMapUIResource}.
 353      *
 354      * @param keys alternating pairs of {@code keystroke-action key}
 355      *        pairs as described in {@link #loadKeyBindings}
 356      * @return newly created and populated {@code InputMapUIResource}
 357      * @see #loadKeyBindings
 358      *
 359      * @since 1.3
 360      */
 361     public static InputMap makeInputMap(Object[] keys) {
 362         InputMap retMap = new InputMapUIResource();
 363         loadKeyBindings(retMap, keys);
 364         return retMap;
 365     }
 366 
 367     /**
 368      * Creates a {@code ComponentInputMapUIResource} from
 369      * <code>keys</code>. This is a convenience method for creating a




 329      * @see InputMap
 330      * @see KeyStroke#getKeyStroke
 331      */
 332     public static JTextComponent.KeyBinding[] makeKeyBindings(Object[] keyBindingList)
 333     {
 334         JTextComponent.KeyBinding[] rv = new JTextComponent.KeyBinding[keyBindingList.length / 2];
 335 
 336         for(int i = 0; i < rv.length; i ++) {
 337             Object o = keyBindingList[2 * i];
 338             KeyStroke keystroke = (o instanceof KeyStroke)
 339                 ? (KeyStroke) o
 340                 : KeyStroke.getKeyStroke((String) o);
 341             String action = (String) keyBindingList[2 * i + 1];
 342             rv[i] = new JTextComponent.KeyBinding(keystroke, action);
 343         }
 344 
 345         return rv;
 346     }
 347 
 348     /**
 349      * Creates an {@code InputMapUIResource} from <code>keys</code>. This is
 350      * a convenience method for creating a new {@code InputMapUIResource},
 351      * invoking {@code loadKeyBindings(map, keys)}, and returning the
 352      * {@code InputMapUIResource}.
 353      *
 354      * @param keys alternating pairs of {@code keystroke-action key}
 355      *        pairs as described in {@link #loadKeyBindings}
 356      * @return newly created and populated {@code InputMapUIResource}
 357      * @see #loadKeyBindings
 358      *
 359      * @since 1.3
 360      */
 361     public static InputMap makeInputMap(Object[] keys) {
 362         InputMap retMap = new InputMapUIResource();
 363         loadKeyBindings(retMap, keys);
 364         return retMap;
 365     }
 366 
 367     /**
 368      * Creates a {@code ComponentInputMapUIResource} from
 369      * <code>keys</code>. This is a convenience method for creating a