jdk/src/share/classes/java/awt/KeyEventPostProcessor.java
author chegar
Mon, 17 Jun 2013 14:09:25 +0100
changeset 18178 ee71c923891d
parent 5506 202f599c92aa
child 21264 b6c4288ebb92
permissions -rw-r--r--
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level) Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package java.awt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.awt.event.KeyEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * A KeyEventPostProcessor cooperates with the current KeyboardFocusManager
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * in the final resolution of all unconsumed KeyEvents. KeyEventPostProcessors
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * registered with the current KeyboardFocusManager will receive KeyEvents
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * after the KeyEvents have been dispatched to and handled by their targets.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * KeyEvents that would have been otherwise discarded because no Component in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * the application currently owns the focus will also be forwarded to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * registered KeyEventPostProcessors. This will allow applications to implement
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * features that require global KeyEvent post-handling, such as menu shortcuts.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * Note that the KeyboardFocusManager itself implements KeyEventPostProcessor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * By default, the current KeyboardFocusManager will be the final
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * KeyEventPostProcessor in the chain. The current KeyboardFocusManager cannot
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * be completely deregistered as a KeyEventPostProcessor. However, if a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * KeyEventPostProcessor reports that no further post-processing of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * KeyEvent should take place, the AWT will consider the event fully handled
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * and will take no additional action with regard to the event. (While it is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * possible for client code to register the current KeyboardFocusManager as
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * a KeyEventPostProcessor one or more times, this is usually unnecessary and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * not recommended.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * @author David Mendenhall
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * @see KeyboardFocusManager#addKeyEventPostProcessor
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * @see KeyboardFocusManager#removeKeyEventPostProcessor
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
public interface KeyEventPostProcessor {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * This method is called by the current KeyboardFocusManager, requesting
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * that this KeyEventPostProcessor perform any necessary post-processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * which should be part of the KeyEvent's final resolution. At the time
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * this method is invoked, typically the KeyEvent has already been
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * dispatched to and handled by its target. However, if no Component in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * the application currently owns the focus, then the KeyEvent has not
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * been dispatched to any Component. Typically, KeyEvent post-processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * will be used to implement features which require global KeyEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * post-handling, such as menu shortcuts. Note that if a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * KeyEventPostProcessor wishes to dispatch the KeyEvent, it must use
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * <code>redispatchEvent</code> to prevent the AWT from recursively
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * requesting that this KeyEventPostProcessor perform post-processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * of the event again.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * If an implementation of this method returns <code>false</code>, then the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * KeyEvent is passed to the next KeyEventPostProcessor in the chain,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * ending with the current KeyboardFocusManager. If an implementation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * returns <code>true</code>, the KeyEvent is assumed to have been fully
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * handled (although this need not be the case), and the AWT will take no
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * further action with regard to the KeyEvent. If an implementation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * consumes the KeyEvent but returns <code>false</code>, the consumed
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * event will still be passed to the next KeyEventPostProcessor in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * chain. It is important for developers to check whether the KeyEvent has
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * been consumed before performing any post-processing of the KeyEvent. By
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * default, the current KeyboardFocusManager will perform no post-
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * processing in response to a consumed KeyEvent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * @param e the KeyEvent to post-process
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * @return <code>true</code> if the AWT should take no further action with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     *         regard to the KeyEvent; <code>false</code> otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * @see KeyboardFocusManager#redispatchEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    boolean postProcessKeyEvent(KeyEvent e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
}