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;
27
28 import java.awt.datatransfer.Clipboard;
29 import java.awt.dnd.DragGestureListener;
30 import java.awt.dnd.DragGestureRecognizer;
31 import java.awt.dnd.DragSource;
32 import java.awt.event.*;
33 import java.awt.im.InputMethodHighlight;
34 import java.awt.image.ColorModel;
35 import java.awt.image.ImageObserver;
36 import java.awt.image.ImageProducer;
37 import java.beans.PropertyChangeEvent;
38 import java.beans.PropertyChangeListener;
39 import java.beans.PropertyChangeSupport;
40 import java.io.File;
41 import java.io.FileInputStream;
42 import java.net.URL;
43 import java.util.ArrayList;
44 import java.util.EventListener;
45 import java.util.HashMap;
46 import java.util.Map;
47 import java.util.MissingResourceException;
48 import java.util.Properties;
49 import java.util.ResourceBundle;
50 import java.util.StringTokenizer;
51 import java.util.WeakHashMap;
52
53 import sun.awt.AWTAccessor;
54 import sun.awt.AWTPermissions;
55 import sun.awt.AppContext;
56 import sun.awt.HeadlessToolkit;
57 import sun.awt.PeerEvent;
58 import sun.awt.SunToolkit;
59
60 import java.security.AccessController;
61 import java.security.PrivilegedAction;
62 import java.util.Arrays;
63 import java.util.ServiceLoader;
64 import java.util.Set;
65 import java.util.stream.Collectors;
66 import javax.accessibility.AccessibilityProvider;
67
68 /**
69 * This class is the abstract superclass of all actual
70 * implementations of the Abstract Window Toolkit. Subclasses of
71 * the {@code Toolkit} class are used to bind the various components
72 * to particular native toolkit implementations.
73 * <p>
74 * Many GUI events may be delivered to user
75 * asynchronously, if the opposite is not specified explicitly.
76 * As well as
77 * many GUI operations may be performed asynchronously.
78 * This fact means that if the state of a component is set, and then
79 * the state immediately queried, the returned value may not yet
80 * reflect the requested change. This behavior includes, but is not
81 * limited to:
82 * <ul>
83 * <li>Scrolling to a specified position.
84 * <br>For example, calling {@code ScrollPane.setScrollPosition}
85 * and then {@code getScrollPosition} may return an incorrect
86 * value if the original request has not yet been processed.
87 *
1048 }
1049
1050 /**
1051 * Determines which modifier key is the appropriate accelerator
1052 * key for menu shortcuts.
1053 * <p>
1054 * Menu shortcuts, which are embodied in the
1055 * {@code MenuShortcut} class, are handled by the
1056 * {@code MenuBar} class.
1057 * <p>
1058 * By default, this method returns {@code Event.CTRL_MASK}.
1059 * Toolkit implementations should override this method if the
1060 * <b>Control</b> key isn't the correct key for accelerators.
1061 * @return the modifier mask on the {@code Event} class
1062 * that is used for menu shortcuts on this toolkit.
1063 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
1064 * returns true
1065 * @see java.awt.GraphicsEnvironment#isHeadless
1066 * @see java.awt.MenuBar
1067 * @see java.awt.MenuShortcut
1068 * @since 1.1
1069 */
1070 @SuppressWarnings("deprecation")
1071 public int getMenuShortcutKeyMask() throws HeadlessException {
1072 GraphicsEnvironment.checkHeadless();
1073
1074 return Event.CTRL_MASK;
1075 }
1076
1077 /**
1078 * Returns whether the given locking key on the keyboard is currently in
1079 * its "on" state.
1080 * Valid key codes are
1081 * {@link java.awt.event.KeyEvent#VK_CAPS_LOCK VK_CAPS_LOCK},
1082 * {@link java.awt.event.KeyEvent#VK_NUM_LOCK VK_NUM_LOCK},
1083 * {@link java.awt.event.KeyEvent#VK_SCROLL_LOCK VK_SCROLL_LOCK}, and
1084 * {@link java.awt.event.KeyEvent#VK_KANA_LOCK VK_KANA_LOCK}.
1085 *
1086 * @param keyCode the key code
1087 * @return {@code true} if the given key is currently in its "on" state;
1088 * otherwise {@code false}
1089 * @exception java.lang.IllegalArgumentException if {@code keyCode}
1090 * is not one of the valid key codes
1091 * @exception java.lang.UnsupportedOperationException if the host system doesn't
1092 * allow getting the state of this key programmatically, or if the keyboard
1093 * doesn't have this key
1094 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
1095 * returns true
1096 * @see java.awt.GraphicsEnvironment#isHeadless
1097 * @since 1.3
|
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;
27
28 import java.awt.datatransfer.Clipboard;
29 import java.awt.dnd.DragGestureListener;
30 import java.awt.dnd.DragGestureRecognizer;
31 import java.awt.dnd.DragSource;
32 import java.awt.event.AWTEventListener;
33 import java.awt.event.AWTEventListenerProxy;
34 import java.awt.event.ActionEvent;
35 import java.awt.event.AdjustmentEvent;
36 import java.awt.event.ComponentEvent;
37 import java.awt.event.ContainerEvent;
38 import java.awt.event.FocusEvent;
39 import java.awt.event.HierarchyEvent;
40 import java.awt.event.InputEvent;
41 import java.awt.event.InputMethodEvent;
42 import java.awt.event.InvocationEvent;
43 import java.awt.event.ItemEvent;
44 import java.awt.event.KeyEvent;
45 import java.awt.event.MouseEvent;
46 import java.awt.event.PaintEvent;
47 import java.awt.event.TextEvent;
48 import java.awt.event.WindowEvent;
49 import java.awt.im.InputMethodHighlight;
50 import java.awt.image.ColorModel;
51 import java.awt.image.ImageObserver;
52 import java.awt.image.ImageProducer;
53 import java.beans.PropertyChangeEvent;
54 import java.beans.PropertyChangeListener;
55 import java.beans.PropertyChangeSupport;
56 import java.io.File;
57 import java.io.FileInputStream;
58 import java.net.URL;
59 import java.security.AccessController;
60 import java.security.PrivilegedAction;
61 import java.util.ArrayList;
62 import java.util.Arrays;
63 import java.util.EventListener;
64 import java.util.HashMap;
65 import java.util.Map;
66 import java.util.MissingResourceException;
67 import java.util.Properties;
68 import java.util.ResourceBundle;
69 import java.util.ServiceLoader;
70 import java.util.Set;
71 import java.util.WeakHashMap;
72 import java.util.stream.Collectors;
73
74 import javax.accessibility.AccessibilityProvider;
75
76 import sun.awt.AWTAccessor;
77 import sun.awt.AWTPermissions;
78 import sun.awt.AppContext;
79 import sun.awt.HeadlessToolkit;
80 import sun.awt.PeerEvent;
81 import sun.awt.SunToolkit;
82
83 /**
84 * This class is the abstract superclass of all actual
85 * implementations of the Abstract Window Toolkit. Subclasses of
86 * the {@code Toolkit} class are used to bind the various components
87 * to particular native toolkit implementations.
88 * <p>
89 * Many GUI events may be delivered to user
90 * asynchronously, if the opposite is not specified explicitly.
91 * As well as
92 * many GUI operations may be performed asynchronously.
93 * This fact means that if the state of a component is set, and then
94 * the state immediately queried, the returned value may not yet
95 * reflect the requested change. This behavior includes, but is not
96 * limited to:
97 * <ul>
98 * <li>Scrolling to a specified position.
99 * <br>For example, calling {@code ScrollPane.setScrollPosition}
100 * and then {@code getScrollPosition} may return an incorrect
101 * value if the original request has not yet been processed.
102 *
1063 }
1064
1065 /**
1066 * Determines which modifier key is the appropriate accelerator
1067 * key for menu shortcuts.
1068 * <p>
1069 * Menu shortcuts, which are embodied in the
1070 * {@code MenuShortcut} class, are handled by the
1071 * {@code MenuBar} class.
1072 * <p>
1073 * By default, this method returns {@code Event.CTRL_MASK}.
1074 * Toolkit implementations should override this method if the
1075 * <b>Control</b> key isn't the correct key for accelerators.
1076 * @return the modifier mask on the {@code Event} class
1077 * that is used for menu shortcuts on this toolkit.
1078 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
1079 * returns true
1080 * @see java.awt.GraphicsEnvironment#isHeadless
1081 * @see java.awt.MenuBar
1082 * @see java.awt.MenuShortcut
1083 * @deprecated It is recommended that extended modifier keys and
1084 * {@link #getMenuShortcutKeyMaskEx()} be used instead
1085 * @since 1.1
1086 */
1087 @Deprecated(since = "10")
1088 public int getMenuShortcutKeyMask() throws HeadlessException {
1089 GraphicsEnvironment.checkHeadless();
1090
1091 return Event.CTRL_MASK;
1092 }
1093
1094 /**
1095 * Determines which extended modifier key is the appropriate accelerator
1096 * key for menu shortcuts.
1097 * <p>
1098 * Menu shortcuts, which are embodied in the {@code MenuShortcut} class, are
1099 * handled by the {@code MenuBar} class.
1100 * <p>
1101 * By default, this method returns {@code InputEvent.CTRL_DOWN_MASK}.
1102 * Toolkit implementations should override this method if the
1103 * <b>Control</b> key isn't the correct key for accelerators.
1104 *
1105 * @return the modifier mask on the {@code InputEvent} class that is used
1106 * for menu shortcuts on this toolkit
1107 * @throws HeadlessException if GraphicsEnvironment.isHeadless() returns
1108 * true
1109 * @see java.awt.GraphicsEnvironment#isHeadless
1110 * @see java.awt.MenuBar
1111 * @see java.awt.MenuShortcut
1112 * @since 1.1
1113 */
1114 public int getMenuShortcutKeyMaskEx() throws HeadlessException {
1115 GraphicsEnvironment.checkHeadless();
1116
1117 return InputEvent.CTRL_DOWN_MASK;
1118 }
1119
1120 /**
1121 * Returns whether the given locking key on the keyboard is currently in
1122 * its "on" state.
1123 * Valid key codes are
1124 * {@link java.awt.event.KeyEvent#VK_CAPS_LOCK VK_CAPS_LOCK},
1125 * {@link java.awt.event.KeyEvent#VK_NUM_LOCK VK_NUM_LOCK},
1126 * {@link java.awt.event.KeyEvent#VK_SCROLL_LOCK VK_SCROLL_LOCK}, and
1127 * {@link java.awt.event.KeyEvent#VK_KANA_LOCK VK_KANA_LOCK}.
1128 *
1129 * @param keyCode the key code
1130 * @return {@code true} if the given key is currently in its "on" state;
1131 * otherwise {@code false}
1132 * @exception java.lang.IllegalArgumentException if {@code keyCode}
1133 * is not one of the valid key codes
1134 * @exception java.lang.UnsupportedOperationException if the host system doesn't
1135 * allow getting the state of this key programmatically, or if the keyboard
1136 * doesn't have this key
1137 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
1138 * returns true
1139 * @see java.awt.GraphicsEnvironment#isHeadless
1140 * @since 1.3
|