src/share/classes/java/awt/Component.java

Print this page




7152      *    <td>none</td>
7153      * </tr>
7154      * </table>
7155      *
7156      * To disable a traversal key, use an empty Set; Collections.EMPTY_SET is
7157      * recommended.
7158      * <p>
7159      * Using the AWTKeyStroke API, client code can specify on which of two
7160      * specific KeyEvents, KEY_PRESSED or KEY_RELEASED, the focus traversal
7161      * operation will occur. Regardless of which KeyEvent is specified,
7162      * however, all KeyEvents related to the focus traversal key, including the
7163      * associated KEY_TYPED event, will be consumed, and will not be dispatched
7164      * to any Component. It is a runtime error to specify a KEY_TYPED event as
7165      * mapping to a focus traversal operation, or to map the same event to
7166      * multiple default focus traversal operations.
7167      * <p>
7168      * If a value of null is specified for the Set, this Component inherits the
7169      * Set from its parent. If all ancestors of this Component have null
7170      * specified for the Set, then the current KeyboardFocusManager's default
7171      * Set is used.




7172      *
7173      * @param id one of KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
7174      *        KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, or
7175      *        KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS
7176      * @param keystrokes the Set of AWTKeyStroke for the specified operation
7177      * @see #getFocusTraversalKeys
7178      * @see KeyboardFocusManager#FORWARD_TRAVERSAL_KEYS
7179      * @see KeyboardFocusManager#BACKWARD_TRAVERSAL_KEYS
7180      * @see KeyboardFocusManager#UP_CYCLE_TRAVERSAL_KEYS
7181      * @throws IllegalArgumentException if id is not one of
7182      *         KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
7183      *         KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, or
7184      *         KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, or if keystrokes
7185      *         contains null, or if any Object in keystrokes is not an
7186      *         AWTKeyStroke, or if any keystroke represents a KEY_TYPED event,
7187      *         or if any keystroke already maps to another focus traversal
7188      *         operation for this Component
7189      * @since 1.4
7190      * @beaninfo
7191      *       bound: true
7192      */
7193     public void setFocusTraversalKeys(int id,
7194                                       Set<? extends AWTKeyStroke> keystrokes)
7195     {
7196         if (id < 0 || id >= KeyboardFocusManager.TRAVERSAL_KEY_LENGTH - 1) {
7197             throw new IllegalArgumentException("invalid focus traversal key identifier");
7198         }
7199 
7200         setFocusTraversalKeys_NoIDCheck(id, keystrokes);
7201     }
7202 
7203     /**
7204      * Returns the Set of focus traversal keys for a given traversal operation
7205      * for this Component. (See
7206      * <code>setFocusTraversalKeys</code> for a full description of each key.)




7152      *    <td>none</td>
7153      * </tr>
7154      * </table>
7155      *
7156      * To disable a traversal key, use an empty Set; Collections.EMPTY_SET is
7157      * recommended.
7158      * <p>
7159      * Using the AWTKeyStroke API, client code can specify on which of two
7160      * specific KeyEvents, KEY_PRESSED or KEY_RELEASED, the focus traversal
7161      * operation will occur. Regardless of which KeyEvent is specified,
7162      * however, all KeyEvents related to the focus traversal key, including the
7163      * associated KEY_TYPED event, will be consumed, and will not be dispatched
7164      * to any Component. It is a runtime error to specify a KEY_TYPED event as
7165      * mapping to a focus traversal operation, or to map the same event to
7166      * multiple default focus traversal operations.
7167      * <p>
7168      * If a value of null is specified for the Set, this Component inherits the
7169      * Set from its parent. If all ancestors of this Component have null
7170      * specified for the Set, then the current KeyboardFocusManager's default
7171      * Set is used.
7172      * <p>
7173      * This method may throw a <code>ClassCastException</code> if any 
7174      * <code>Object</code> in <code>keystrokes</code> is not an 
7175      * <code>AWTKeyStroke</code>.
7176      *
7177      * @param id one of KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
7178      *        KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, or
7179      *        KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS
7180      * @param keystrokes the Set of AWTKeyStroke for the specified operation
7181      * @see #getFocusTraversalKeys
7182      * @see KeyboardFocusManager#FORWARD_TRAVERSAL_KEYS
7183      * @see KeyboardFocusManager#BACKWARD_TRAVERSAL_KEYS
7184      * @see KeyboardFocusManager#UP_CYCLE_TRAVERSAL_KEYS
7185      * @throws IllegalArgumentException if id is not one of
7186      *         KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
7187      *         KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, or
7188      *         KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, or if keystrokes
7189      *         contains null, or if any keystroke represents a KEY_TYPED event,

7190      *         or if any keystroke already maps to another focus traversal
7191      *         operation for this Component
7192      * @since 1.4
7193      * @beaninfo
7194      *       bound: true
7195      */
7196     public void setFocusTraversalKeys(int id,
7197                                       Set<? extends AWTKeyStroke> keystrokes)
7198     {
7199         if (id < 0 || id >= KeyboardFocusManager.TRAVERSAL_KEY_LENGTH - 1) {
7200             throw new IllegalArgumentException("invalid focus traversal key identifier");
7201         }
7202 
7203         setFocusTraversalKeys_NoIDCheck(id, keystrokes);
7204     }
7205 
7206     /**
7207      * Returns the Set of focus traversal keys for a given traversal operation
7208      * for this Component. (See
7209      * <code>setFocusTraversalKeys</code> for a full description of each key.)