1 /*
2 * Copyright (c) 1996, 2008, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package java.awt.event;
27
28 import java.awt.Component;
29 import javax.tools.annotation.GenerateNativeHeader;
30 import sun.awt.AppContext;
31 import sun.awt.SunToolkit;
32
33 /**
34 * A low-level event which indicates that a Component has gained or lost the
35 * input focus. This low-level event is generated by a Component (such as a
36 * TextField). The event is passed to every <code>FocusListener</code> or
37 * <code>FocusAdapter</code> object which registered to receive such events
38 * using the Component's <code>addFocusListener</code> method. (<code>
39 * FocusAdapter</code> objects implement the <code>FocusListener</code>
40 * interface.) Each such listener object gets this <code>FocusEvent</code> when
41 * the event occurs.
42 * <p>
43 * There are two levels of focus events: permanent and temporary. Permanent
44 * focus change events occur when focus is directly moved from one Component to
45 * another, such as through a call to requestFocus() or as the user uses the
46 * TAB key to traverse Components. Temporary focus change events occur when
47 * focus is temporarily lost for a Component as the indirect result of another
48 * operation, such as Window deactivation or a Scrollbar drag. In this case,
49 * the original focus state will automatically be restored once that operation
50 * is finished, or, for the case of Window deactivation, when the Window is
51 * reactivated. Both permanent and temporary focus events are delivered using
52 * the FOCUS_GAINED and FOCUS_LOST event ids; the level may be distinguished in
53 * the event using the isTemporary() method.
54 * <p>
55 * An unspecified behavior will be caused if the {@code id} parameter
56 * of any particular {@code FocusEvent} instance is not
57 * in the range from {@code FOCUS_FIRST} to {@code FOCUS_LAST}.
58 *
59 * @see FocusAdapter
60 * @see FocusListener
61 * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/focuslistener.html">Tutorial: Writing a Focus Listener</a>
62 *
63 * @author Carl Quinn
64 * @author Amy Fowler
65 * @since 1.1
66 */
67 /* No native methods here, but the constants are needed in the supporting JNI code */
68 @GenerateNativeHeader
69 public class FocusEvent extends ComponentEvent {
70
71 /**
72 * The first number in the range of ids used for focus events.
73 */
74 public static final int FOCUS_FIRST = 1004;
75
76 /**
77 * The last number in the range of ids used for focus events.
78 */
79 public static final int FOCUS_LAST = 1005;
80
81 /**
82 * This event indicates that the Component is now the focus owner.
83 */
84 public static final int FOCUS_GAINED = FOCUS_FIRST; //Event.GOT_FOCUS
85
86 /**
87 * This event indicates that the Component is no longer the focus owner.
88 */
|
1 /*
2 * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package java.awt.event;
27
28 import java.awt.Component;
29 import sun.awt.AppContext;
30 import sun.awt.SunToolkit;
31
32 /**
33 * A low-level event which indicates that a Component has gained or lost the
34 * input focus. This low-level event is generated by a Component (such as a
35 * TextField). The event is passed to every <code>FocusListener</code> or
36 * <code>FocusAdapter</code> object which registered to receive such events
37 * using the Component's <code>addFocusListener</code> method. (<code>
38 * FocusAdapter</code> objects implement the <code>FocusListener</code>
39 * interface.) Each such listener object gets this <code>FocusEvent</code> when
40 * the event occurs.
41 * <p>
42 * There are two levels of focus events: permanent and temporary. Permanent
43 * focus change events occur when focus is directly moved from one Component to
44 * another, such as through a call to requestFocus() or as the user uses the
45 * TAB key to traverse Components. Temporary focus change events occur when
46 * focus is temporarily lost for a Component as the indirect result of another
47 * operation, such as Window deactivation or a Scrollbar drag. In this case,
48 * the original focus state will automatically be restored once that operation
49 * is finished, or, for the case of Window deactivation, when the Window is
50 * reactivated. Both permanent and temporary focus events are delivered using
51 * the FOCUS_GAINED and FOCUS_LOST event ids; the level may be distinguished in
52 * the event using the isTemporary() method.
53 * <p>
54 * An unspecified behavior will be caused if the {@code id} parameter
55 * of any particular {@code FocusEvent} instance is not
56 * in the range from {@code FOCUS_FIRST} to {@code FOCUS_LAST}.
57 *
58 * @see FocusAdapter
59 * @see FocusListener
60 * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/focuslistener.html">Tutorial: Writing a Focus Listener</a>
61 *
62 * @author Carl Quinn
63 * @author Amy Fowler
64 * @since 1.1
65 */
66 public class FocusEvent extends ComponentEvent {
67
68 /**
69 * The first number in the range of ids used for focus events.
70 */
71 public static final int FOCUS_FIRST = 1004;
72
73 /**
74 * The last number in the range of ids used for focus events.
75 */
76 public static final int FOCUS_LAST = 1005;
77
78 /**
79 * This event indicates that the Component is now the focus owner.
80 */
81 public static final int FOCUS_GAINED = FOCUS_FIRST; //Event.GOT_FOCUS
82
83 /**
84 * This event indicates that the Component is no longer the focus owner.
85 */
|