1 /*
2 * Copyright (c) 2000, 2015, 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
57 * <a href="https://docs.oracle.com/javase/tutorial/uiswing/misc/focus.html">
58 * How to Use the Focus Subsystem</a>,
59 * a section in <em>The Java Tutorial</em>, and the
60 * <a href="../../java/awt/doc-files/FocusSpec.html">Focus Specification</a>
61 * for more information.
62 *
63 * @author David Mendenhall
64 *
65 * @see Container#getComponents
66 * @see Component#isFocusable
67 * @see Component#setFocusable
68 * @since 1.4
69 */
70 public class DefaultFocusTraversalPolicy
71 extends ContainerOrderFocusTraversalPolicy
72 {
73 /*
74 * serialVersionUID
75 */
76 private static final long serialVersionUID = 8876966522510157497L;
77
78 /**
79 * Determines whether a Component is an acceptable choice as the new
80 * focus owner. The Component must be visible, displayable, and enabled
81 * to be accepted. If client code has explicitly set the focusability
82 * of the Component by either overriding
83 * {@code Component.isFocusTraversable()} or
84 * {@code Component.isFocusable()}, or by calling
85 * {@code Component.setFocusable()}, then the Component will be
86 * accepted if and only if it is focusable. If, however, the Component is
87 * relying on default focusability, then all Canvases, Labels, Panels,
88 * Scrollbars, ScrollPanes, Windows, and lightweight Components will be
89 * rejected.
90 *
91 * @param aComponent the Component whose fitness as a focus owner is to
92 * be tested
93 * @return {@code true} if aComponent meets the above requirements;
94 * {@code false} otherwise
95 */
96 protected boolean accept(Component aComponent) {
|
1 /*
2 * Copyright (c) 2000, 2020, 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
57 * <a href="https://docs.oracle.com/javase/tutorial/uiswing/misc/focus.html">
58 * How to Use the Focus Subsystem</a>,
59 * a section in <em>The Java Tutorial</em>, and the
60 * <a href="../../java/awt/doc-files/FocusSpec.html">Focus Specification</a>
61 * for more information.
62 *
63 * @author David Mendenhall
64 *
65 * @see Container#getComponents
66 * @see Component#isFocusable
67 * @see Component#setFocusable
68 * @since 1.4
69 */
70 public class DefaultFocusTraversalPolicy
71 extends ContainerOrderFocusTraversalPolicy
72 {
73 /*
74 * serialVersionUID
75 */
76 private static final long serialVersionUID = 8876966522510157497L;
77
78 /**
79 * Constructs a {@code DefaultFocusTraversalPolicy}.
80 */
81 public DefaultFocusTraversalPolicy() {}
82
83 /**
84 * Determines whether a Component is an acceptable choice as the new
85 * focus owner. The Component must be visible, displayable, and enabled
86 * to be accepted. If client code has explicitly set the focusability
87 * of the Component by either overriding
88 * {@code Component.isFocusTraversable()} or
89 * {@code Component.isFocusable()}, or by calling
90 * {@code Component.setFocusable()}, then the Component will be
91 * accepted if and only if it is focusable. If, however, the Component is
92 * relying on default focusability, then all Canvases, Labels, Panels,
93 * Scrollbars, ScrollPanes, Windows, and lightweight Components will be
94 * rejected.
95 *
96 * @param aComponent the Component whose fitness as a focus owner is to
97 * be tested
98 * @return {@code true} if aComponent meets the above requirements;
99 * {@code false} otherwise
100 */
101 protected boolean accept(Component aComponent) {
|