jdk/src/java.desktop/share/classes/java/awt/Toolkit.java
author aghaisas
Fri, 15 Jul 2016 15:13:09 +0530
changeset 39863 bd45c335847b
parent 38396 29de73c166ce
child 40997 b9a1c4fe2518
permissions -rw-r--r--
8159956: EXCEPTION_ACCESS_VIOLATION in sun.awt.windows.ThemeReader.getThemeMargins Reviewed-by: prr, ssadetsky
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
38396
29de73c166ce 8027324: The spec for Toolkit.setDynamicLayout() and Toolkit.isDynamicLayoutActive() needs to be clarified
serb
parents: 38388
diff changeset
     2
 * Copyright (c) 1995, 2016, 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: 3965
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: 3965
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: 3965
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3965
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3965
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.awt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
30471
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 29886
diff changeset
    28
import java.awt.datatransfer.Clipboard;
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 29886
diff changeset
    29
import java.awt.dnd.DragGestureListener;
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 29886
diff changeset
    30
import java.awt.dnd.DragGestureRecognizer;
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 29886
diff changeset
    31
import java.awt.dnd.DragSource;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.awt.im.InputMethodHighlight;
30471
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 29886
diff changeset
    34
import java.awt.image.ColorModel;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.awt.image.ImageObserver;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.awt.image.ImageProducer;
30471
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 29886
diff changeset
    37
import java.beans.PropertyChangeEvent;
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 29886
diff changeset
    38
import java.beans.PropertyChangeListener;
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 29886
diff changeset
    39
import java.beans.PropertyChangeSupport;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.io.File;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import java.io.FileInputStream;
30471
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 29886
diff changeset
    42
import java.net.URL;
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 29886
diff changeset
    43
import java.util.ArrayList;
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 29886
diff changeset
    44
import java.util.EventListener;
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 29886
diff changeset
    45
import java.util.HashMap;
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 29886
diff changeset
    46
import java.util.Map;
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 29886
diff changeset
    47
import java.util.MissingResourceException;
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 29886
diff changeset
    48
import java.util.Properties;
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 29886
diff changeset
    49
import java.util.ResourceBundle;
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 29886
diff changeset
    50
import java.util.StringTokenizer;
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 29886
diff changeset
    51
import java.util.WeakHashMap;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
30471
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 29886
diff changeset
    53
import sun.awt.AWTAccessor;
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 29886
diff changeset
    54
import sun.awt.AWTPermissions;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
import sun.awt.AppContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
import sun.awt.HeadlessToolkit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
import sun.awt.PeerEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
import sun.awt.SunToolkit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
31438
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
    60
import java.security.AccessController;
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
    61
import java.security.PrivilegedAction;
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
    62
import java.util.Arrays;
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
    63
import java.util.ServiceLoader;
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
    64
import java.util.Set;
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
    65
import java.util.stream.Collectors;
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
    66
import javax.accessibility.AccessibilityProvider;
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
    67
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * This class is the abstract superclass of all actual
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * implementations of the Abstract Window Toolkit. Subclasses of
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
    71
 * the {@code Toolkit} class are used to bind the various components
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * to particular native toolkit implementations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * Many GUI events may be delivered to user
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * asynchronously, if the opposite is not specified explicitly.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * As well as
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * many GUI operations may be performed asynchronously.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * This fact means that if the state of a component is set, and then
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * the state immediately queried, the returned value may not yet
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * reflect the requested change.  This behavior includes, but is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * limited to:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * <li>Scrolling to a specified position.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
    84
 * <br>For example, calling {@code ScrollPane.setScrollPosition}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
    85
 *     and then {@code getScrollPosition} may return an incorrect
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 *     value if the original request has not yet been processed.
21957
97758de70fbd 8028019: AWT Doclint warning/error cleanup
rriggs
parents: 21278
diff changeset
    87
 *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * <li>Moving the focus from one component to another.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 * <br>For more information, see
20455
f6f9a0c2796b 8020688: Broken links in documentation at http://docs.oracle.com/javase/6/docs/api/index.
mcherkas
parents: 20154
diff changeset
    90
 * <a href="http://docs.oracle.com/javase/tutorial/uiswing/misc/focus.html#transferTiming">Timing
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * Focus Transfers</a>, a section in
38388
84ab1f133f16 8143346: Broken link in java.beans.XMLEncoder
serb
parents: 36511
diff changeset
    92
 * <a href="http://docs.oracle.com/javase/tutorial/uiswing/">The Swing
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * Tutorial</a>.
21957
97758de70fbd 8028019: AWT Doclint warning/error cleanup
rriggs
parents: 21278
diff changeset
    94
 *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 * <li>Making a top-level container visible.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
    96
 * <br>Calling {@code setVisible(true)} on a {@code Window},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
    97
 *     {@code Frame} or {@code Dialog} may occur
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 *     asynchronously.
21957
97758de70fbd 8028019: AWT Doclint warning/error cleanup
rriggs
parents: 21278
diff changeset
    99
 *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 * <li>Setting the size or location of a top-level container.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   101
 * <br>Calls to {@code setSize}, {@code setBounds} or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   102
 *     {@code setLocation} on a {@code Window},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   103
 *     {@code Frame} or {@code Dialog} are forwarded
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
 *     to the underlying window management system and may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 *     ignored or modified.  See {@link java.awt.Window} for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 *     more information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 * Most applications should not call any of the methods in this
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   110
 * class directly. The methods defined by {@code Toolkit} are
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 * the "glue" that joins the platform-independent classes in the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   112
 * {@code java.awt} package with their counterparts in
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   113
 * {@code java.awt.peer}. Some methods defined by
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   114
 * {@code Toolkit} query the native operating system directly.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
 * @author      Sami Shaio
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
 * @author      Arthur van Hoff
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
 * @author      Fred Ecks
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23717
diff changeset
   119
 * @since       1.0
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
public abstract class Toolkit {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    // The following method is called by the private method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    // <code>updateSystemColors</code> in <code>SystemColor</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * Fills in the integer array that is supplied as an argument
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * with the current system color values.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * @param     systemColors an integer array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * @see       java.awt.GraphicsEnvironment#isHeadless
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23717
diff changeset
   134
     * @since     1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    protected void loadSystemColors(int[] systemColors)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        throws HeadlessException {
9656
b9011986e4c8 7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents: 9475
diff changeset
   138
        GraphicsEnvironment.checkHeadless();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
20154
551a86159e69 7172833: For default java.awt.Toolkit impl methods java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 20147
diff changeset
   141
    /**
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * Controls whether the layout of Containers is validated dynamically
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * during resizing, or statically, after resizing is complete.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * Use {@code isDynamicLayoutActive()} to detect if this feature enabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * in this program and is supported by this operating system
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * and/or window manager.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * Note that this feature is supported not on all platforms, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * conversely, that this feature cannot be turned off on some platforms.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * On these platforms where dynamic layout during resizing is not supported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * (or is always supported), setting this property has no effect.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * Note that this feature can be set or unset as a property of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * operating system or window manager on some platforms.  On such
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * platforms, the dynamic resize property must be set at the operating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * system or window manager level before this method can take effect.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * This method does not change support or settings of the underlying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * operating system or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * window manager.  The OS/WM support can be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * queried using getDesktopProperty("awt.dynamicLayoutSupported") method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * @param     dynamic  If true, Containers should re-layout their
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     *            components as the Container is being resized.  If false,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     *            the layout will be validated after resizing is completed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     *            returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * @see       #isDynamicLayoutSet()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * @see       #isDynamicLayoutActive()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * @see       #getDesktopProperty(String propertyName)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * @since     1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     */
20154
551a86159e69 7172833: For default java.awt.Toolkit impl methods java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 20147
diff changeset
   171
    public void setDynamicLayout(final boolean dynamic)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        throws HeadlessException {
9656
b9011986e4c8 7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents: 9475
diff changeset
   173
        GraphicsEnvironment.checkHeadless();
20154
551a86159e69 7172833: For default java.awt.Toolkit impl methods java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 20147
diff changeset
   174
        if (this != getDefaultToolkit()) {
551a86159e69 7172833: For default java.awt.Toolkit impl methods java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 20147
diff changeset
   175
            getDefaultToolkit().setDynamicLayout(dynamic);
551a86159e69 7172833: For default java.awt.Toolkit impl methods java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 20147
diff changeset
   176
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * Returns whether the layout of Containers is validated dynamically
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * during resizing, or statically, after resizing is complete.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * Note: this method returns the value that was set programmatically;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * it does not reflect support at the level of the operating system
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * or window manager for dynamic layout on resizing, or the current
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * operating system or window manager settings.  The OS/WM support can
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * be queried using getDesktopProperty("awt.dynamicLayoutSupported").
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * @return    true if validation of Containers is done dynamically,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     *            false if validation is done after resizing is finished.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     *            returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * @see       #setDynamicLayout(boolean dynamic)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * @see       #isDynamicLayoutActive()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * @see       #getDesktopProperty(String propertyName)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * @since     1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    protected boolean isDynamicLayoutSet()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        throws HeadlessException {
9656
b9011986e4c8 7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents: 9475
diff changeset
   200
        GraphicsEnvironment.checkHeadless();
b9011986e4c8 7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents: 9475
diff changeset
   201
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        if (this != Toolkit.getDefaultToolkit()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            return Toolkit.getDefaultToolkit().isDynamicLayoutSet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    /**
38396
29de73c166ce 8027324: The spec for Toolkit.setDynamicLayout() and Toolkit.isDynamicLayoutActive() needs to be clarified
serb
parents: 38388
diff changeset
   210
     * Returns whether dynamic layout of Containers on resize is currently
29de73c166ce 8027324: The spec for Toolkit.setDynamicLayout() and Toolkit.isDynamicLayoutActive() needs to be clarified
serb
parents: 38388
diff changeset
   211
     * enabled on the underlying operating system and/or window manager). If the
29de73c166ce 8027324: The spec for Toolkit.setDynamicLayout() and Toolkit.isDynamicLayoutActive() needs to be clarified
serb
parents: 38388
diff changeset
   212
     * platform supports it, {@code setDynamicLayout(boolean)} may be used to
29de73c166ce 8027324: The spec for Toolkit.setDynamicLayout() and Toolkit.isDynamicLayoutActive() needs to be clarified
serb
parents: 38388
diff changeset
   213
     * programmatically enable or disable platform dynamic layout. Regardless of
29de73c166ce 8027324: The spec for Toolkit.setDynamicLayout() and Toolkit.isDynamicLayoutActive() needs to be clarified
serb
parents: 38388
diff changeset
   214
     * whether that toggling is supported, or whether {@code true} or {@code
29de73c166ce 8027324: The spec for Toolkit.setDynamicLayout() and Toolkit.isDynamicLayoutActive() needs to be clarified
serb
parents: 38388
diff changeset
   215
     * false} is specified as an argument, or has never been called at all, this
29de73c166ce 8027324: The spec for Toolkit.setDynamicLayout() and Toolkit.isDynamicLayoutActive() needs to be clarified
serb
parents: 38388
diff changeset
   216
     * method will return the active current platform behavior and which will be
29de73c166ce 8027324: The spec for Toolkit.setDynamicLayout() and Toolkit.isDynamicLayoutActive() needs to be clarified
serb
parents: 38388
diff changeset
   217
     * followed by the JDK in determining layout policy during resizing.
29de73c166ce 8027324: The spec for Toolkit.setDynamicLayout() and Toolkit.isDynamicLayoutActive() needs to be clarified
serb
parents: 38388
diff changeset
   218
     * <p>
29de73c166ce 8027324: The spec for Toolkit.setDynamicLayout() and Toolkit.isDynamicLayoutActive() needs to be clarified
serb
parents: 38388
diff changeset
   219
     * If dynamic layout is currently inactive then Containers re-layout their
29de73c166ce 8027324: The spec for Toolkit.setDynamicLayout() and Toolkit.isDynamicLayoutActive() needs to be clarified
serb
parents: 38388
diff changeset
   220
     * components when resizing is completed. As a result the
29de73c166ce 8027324: The spec for Toolkit.setDynamicLayout() and Toolkit.isDynamicLayoutActive() needs to be clarified
serb
parents: 38388
diff changeset
   221
     * {@code Component.validate()} method will be invoked only once per resize.
29de73c166ce 8027324: The spec for Toolkit.setDynamicLayout() and Toolkit.isDynamicLayoutActive() needs to be clarified
serb
parents: 38388
diff changeset
   222
     * If dynamic layout is currently active then Containers re-layout their
29de73c166ce 8027324: The spec for Toolkit.setDynamicLayout() and Toolkit.isDynamicLayoutActive() needs to be clarified
serb
parents: 38388
diff changeset
   223
     * components on every native resize event and the {@code validate()} method
29de73c166ce 8027324: The spec for Toolkit.setDynamicLayout() and Toolkit.isDynamicLayoutActive() needs to be clarified
serb
parents: 38388
diff changeset
   224
     * will be invoked each time. The OS/WM support can be queried using the
29de73c166ce 8027324: The spec for Toolkit.setDynamicLayout() and Toolkit.isDynamicLayoutActive() needs to be clarified
serb
parents: 38388
diff changeset
   225
     * getDesktopProperty("awt.dynamicLayoutSupported") method. This property
29de73c166ce 8027324: The spec for Toolkit.setDynamicLayout() and Toolkit.isDynamicLayoutActive() needs to be clarified
serb
parents: 38388
diff changeset
   226
     * will reflect the platform capability but is not sufficient to tell if it
29de73c166ce 8027324: The spec for Toolkit.setDynamicLayout() and Toolkit.isDynamicLayoutActive() needs to be clarified
serb
parents: 38388
diff changeset
   227
     * is presently enabled.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     *
38396
29de73c166ce 8027324: The spec for Toolkit.setDynamicLayout() and Toolkit.isDynamicLayoutActive() needs to be clarified
serb
parents: 38388
diff changeset
   229
     * @return true if dynamic layout of Containers on resize is currently
29de73c166ce 8027324: The spec for Toolkit.setDynamicLayout() and Toolkit.isDynamicLayoutActive() needs to be clarified
serb
parents: 38388
diff changeset
   230
     *         active, false otherwise.
29de73c166ce 8027324: The spec for Toolkit.setDynamicLayout() and Toolkit.isDynamicLayoutActive() needs to be clarified
serb
parents: 38388
diff changeset
   231
     * @throws HeadlessException if the GraphicsEnvironment.isHeadless() method
29de73c166ce 8027324: The spec for Toolkit.setDynamicLayout() and Toolkit.isDynamicLayoutActive() needs to be clarified
serb
parents: 38388
diff changeset
   232
     *         returns true
29de73c166ce 8027324: The spec for Toolkit.setDynamicLayout() and Toolkit.isDynamicLayoutActive() needs to be clarified
serb
parents: 38388
diff changeset
   233
     * @see #setDynamicLayout(boolean dynamic)
29de73c166ce 8027324: The spec for Toolkit.setDynamicLayout() and Toolkit.isDynamicLayoutActive() needs to be clarified
serb
parents: 38388
diff changeset
   234
     * @see #isDynamicLayoutSet()
29de73c166ce 8027324: The spec for Toolkit.setDynamicLayout() and Toolkit.isDynamicLayoutActive() needs to be clarified
serb
parents: 38388
diff changeset
   235
     * @see #getDesktopProperty(String propertyName)
29de73c166ce 8027324: The spec for Toolkit.setDynamicLayout() and Toolkit.isDynamicLayoutActive() needs to be clarified
serb
parents: 38388
diff changeset
   236
     * @see java.awt.GraphicsEnvironment#isHeadless
29de73c166ce 8027324: The spec for Toolkit.setDynamicLayout() and Toolkit.isDynamicLayoutActive() needs to be clarified
serb
parents: 38388
diff changeset
   237
     * @since 1.4
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    public boolean isDynamicLayoutActive()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        throws HeadlessException {
9656
b9011986e4c8 7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents: 9475
diff changeset
   241
        GraphicsEnvironment.checkHeadless();
b9011986e4c8 7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents: 9475
diff changeset
   242
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        if (this != Toolkit.getDefaultToolkit()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
            return Toolkit.getDefaultToolkit().isDynamicLayoutActive();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * Gets the size of the screen.  On systems with multiple displays, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * primary display is used.  Multi-screen aware display dimensions are
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   253
     * available from {@code GraphicsConfiguration} and
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   254
     * {@code GraphicsDevice}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * @return    the size of this toolkit's screen, in pixels.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * @see       java.awt.GraphicsConfiguration#getBounds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * @see       java.awt.GraphicsDevice#getDisplayMode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    public abstract Dimension getScreenSize()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        throws HeadlessException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * Returns the screen resolution in dots-per-inch.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * @return    this toolkit's screen resolution, in dots-per-inch.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    public abstract int getScreenResolution()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        throws HeadlessException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * Gets the insets of the screen.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   277
     * @param     gc a {@code GraphicsConfiguration}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * @return    the insets of this toolkit's screen, in pixels.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * @since     1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    public Insets getScreenInsets(GraphicsConfiguration gc)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        throws HeadlessException {
9656
b9011986e4c8 7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents: 9475
diff changeset
   286
        GraphicsEnvironment.checkHeadless();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        if (this != Toolkit.getDefaultToolkit()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
            return Toolkit.getDefaultToolkit().getScreenInsets(gc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
            return new Insets(0, 0, 0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * Determines the color model of this toolkit's screen.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   297
     * {@code ColorModel} is an abstract class that
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * encapsulates the ability to translate between the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * pixel values of an image and its red, green, blue,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * and alpha components.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * This toolkit method is called by the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   303
     * {@code getColorModel} method
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   304
     * of the {@code Component} class.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     * @return    the color model of this toolkit's screen.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * @see       java.awt.image.ColorModel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     * @see       java.awt.Component#getColorModel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    public abstract ColorModel getColorModel()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        throws HeadlessException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * Returns the names of the available fonts in this toolkit.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * For 1.1, the following font names are deprecated (the replacement
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * name follows):
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * <li>TimesRoman (use Serif)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * <li>Helvetica (use SansSerif)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     * <li>Courier (use Monospaced)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     * </ul><p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * The ZapfDingbats fontname is also deprecated in 1.1 but the characters
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * are defined in Unicode starting at 0x2700, and as of 1.1 Java supports
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * those characters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * @return    the names of the available fonts in this toolkit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * @deprecated see {@link java.awt.GraphicsEnvironment#getAvailableFontFamilyNames()}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * @see java.awt.GraphicsEnvironment#getAvailableFontFamilyNames()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    public abstract String[] getFontList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     * Gets the screen device metrics for rendering of the font.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * @param     font   a font
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     * @return    the screen metrics of the specified font in this toolkit
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   338
     * @deprecated  As of JDK version 1.2, replaced by the {@code Font}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   339
     *          method {@code getLineMetrics}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     * @see java.awt.font.LineMetrics
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     * @see java.awt.Font#getLineMetrics
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     * @see java.awt.GraphicsEnvironment#getScreenDevices
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
    public abstract FontMetrics getFontMetrics(Font font);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     * Synchronizes this toolkit's graphics state. Some window systems
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     * may do buffering of graphics events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * This method ensures that the display is up-to-date. It is useful
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     * for animation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    public abstract void sync();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     * The default toolkit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
    private static Toolkit toolkit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     * Used internally by the assistive technologies functions; set at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     * init time and used at load time
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    private static String atNames;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     * Initializes properties related to assistive technologies.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     * These properties are used both in the loadAssistiveProperties()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     * function below, as well as other classes in the jdk that depend
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     * on the properties (such as the use of the screen_magnifier_present
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     * property in Java2D hardware acceleration initialization).  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * initialization of the properties must be done before the platform-
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     * specific Toolkit class is instantiated so that all necessary
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     * properties are set up properly before any classes dependent upon them
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     * are initialized.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    private static void initAssistiveTechnologies() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        // Get accessibility properties
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        final String sep = File.separator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        final Properties properties = new Properties();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
11270
d7b0b63bd082 7117334: Warnings cleanup day: reduce number of javac warnings in the java.awt package
bagiras
parents: 10068
diff changeset
   385
        atNames = java.security.AccessController.doPrivileged(
d7b0b63bd082 7117334: Warnings cleanup day: reduce number of javac warnings in the java.awt package
bagiras
parents: 10068
diff changeset
   386
            new java.security.PrivilegedAction<String>() {
d7b0b63bd082 7117334: Warnings cleanup day: reduce number of javac warnings in the java.awt package
bagiras
parents: 10068
diff changeset
   387
            public String run() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
                // Try loading the per-user accessibility properties file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
                    File propsFile = new File(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
                      System.getProperty("user.home") +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
                      sep + ".accessibility.properties");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
                    FileInputStream in =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
                        new FileInputStream(propsFile);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
                    // Inputstream has been buffered in Properties class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
                    properties.load(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
                    in.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
                } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
                    // Per-user accessibility properties file does not exist
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
                // Try loading the system-wide accessibility properties
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
                // file only if a per-user accessibility properties
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
                // file does not exist or is empty.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
                if (properties.size() == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
                        File propsFile = new File(
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents: 25859
diff changeset
   410
                            System.getProperty("java.home") + sep + "conf" +
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
                            sep + "accessibility.properties");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
                        FileInputStream in =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
                            new FileInputStream(propsFile);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
                        // Inputstream has been buffered in Properties class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
                        properties.load(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
                        in.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
                    } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
                        // System-wide accessibility properties file does
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
                        // not exist;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
                // Get whether a screen magnifier is present.  First check
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
                // the system property and then check the properties file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
                String magPresent = System.getProperty("javax.accessibility.screen_magnifier_present");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
                if (magPresent == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
                    magPresent = properties.getProperty("screen_magnifier_present", null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
                    if (magPresent != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
                        System.setProperty("javax.accessibility.screen_magnifier_present", magPresent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
31438
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   434
                // Get the names of any assistive technologies to load.  First
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
                // check the system property and then check the properties
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
                // file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                String classNames = System.getProperty("javax.accessibility.assistive_technologies");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
                if (classNames == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
                    classNames = properties.getProperty("assistive_technologies", null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
                    if (classNames != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                        System.setProperty("javax.accessibility.assistive_technologies", classNames);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
                return classNames;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
        });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
    /**
31438
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   450
     * Rethrow the AWTError but include the cause.
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   451
     *
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   452
     * @param s the error message
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   453
     * @param e the original exception
32491
7b3783f9484d 8133807: java.desktop docs: replace some invalid "@returns" tags
avstepan
parents: 32124
diff changeset
   454
     * @throws the new AWTError including the cause (the original exception)
31438
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   455
     */
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   456
    private static void newAWTError(Throwable e, String s) {
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   457
        AWTError newAWTError = new AWTError(s);
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   458
        newAWTError.initCause(e);
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   459
        throw newAWTError;
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   460
    }
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   461
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   462
    /**
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   463
     * When a service provider for Assistive Technology is not found look for a
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   464
     * supporting class on the class path and instantiate it.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     *
31438
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   466
     * @param atName the name of the class to be loaded
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   467
     */
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   468
    private static void fallbackToLoadClassForAT(String atName) {
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   469
        try {
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   470
            Class<?> c = Class.forName(atName, false, ClassLoader.getSystemClassLoader());
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   471
            c.newInstance();
31438
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   472
        } catch (ClassNotFoundException e) {
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   473
            newAWTError(e, "Assistive Technology not found: " + atName);
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   474
        } catch (InstantiationException e) {
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   475
            newAWTError(e, "Could not instantiate Assistive Technology: " + atName);
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   476
        } catch (IllegalAccessException e) {
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   477
            newAWTError(e, "Could not access Assistive Technology: " + atName);
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   478
        } catch (Exception e) {
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   479
            newAWTError(e, "Error trying to install Assistive Technology: " + atName);
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   480
        }
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   481
    }
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   482
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   483
    /**
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   484
     * Loads accessibility support using the property assistive_technologies.
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   485
     * The form is assistive_technologies= followed by a comma-separated list of
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   486
     * assistive technology providers to load.  The order in which providers are
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   487
     * loaded is determined by the order in which the ServiceLoader discovers
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   488
     * implementations of the AccessibilityProvider interface, not by the order
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   489
     * of provider names in the property list.  When a provider is found its
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   490
     * accessibility implementation will be started by calling the provider's
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   491
     * activate method.  All errors are handled via an AWTError exception.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
    private static void loadAssistiveTechnologies() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        // Load any assistive technologies
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
        if (atNames != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
            ClassLoader cl = ClassLoader.getSystemClassLoader();
31438
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   497
            Set<String> names = Arrays.stream(atNames.split(","))
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   498
                                      .map(String::trim)
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   499
                                      .collect(Collectors.toSet());
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   500
            final Map<String, AccessibilityProvider> providers = new HashMap<>();
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   501
            AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
                try {
31438
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   503
                    for (AccessibilityProvider p : ServiceLoader.load(AccessibilityProvider.class, cl)) {
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   504
                        String name = p.getName();
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   505
                        if (names.contains(name) && !providers.containsKey(name)) {
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   506
                            p.activate();
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   507
                            providers.put(name, p);
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   508
                        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
                    }
31438
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   510
                } catch (java.util.ServiceConfigurationError | Exception e) {
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   511
                    newAWTError(e, "Could not load or activate service provider");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
                }
31438
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   513
                return null;
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   514
            });
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   515
            names.stream()
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   516
                 .filter(n -> !providers.containsKey(n))
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   517
                 .forEach(Toolkit::fallbackToLoadClassForAT);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     * Gets the default toolkit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
     * <p>
31438
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   524
     * If a system property named {@code "java.awt.headless"} is set
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   525
     * to {@code true} then the headless implementation
32124
f5ee581efbb7 8130478: Reconsider "awt.toolkit" property usage in java.awt.Toolkit getDefaultToolkit() method
alexsch
parents: 31438
diff changeset
   526
     * of {@code Toolkit} is used,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
     * otherwise the default platform-specific implementation of
31438
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   528
     * {@code Toolkit} is used.
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   529
     * <p>
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   530
     * If this Toolkit is not a headless implementation and if they exist, service
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   531
     * providers of {@link javax.accessibility.AccessibilityProvider} will be loaded
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   532
     * if specified by the system property
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   533
     * {@code javax.accessibility.assistive_technologies}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     * <p>
31438
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   535
     * An example of setting this property is to invoke Java with
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   536
     * {@code -Djavax.accessibility.assistive_technologies=MyServiceProvider}.
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   537
     * In addition to MyServiceProvider other service providers can be specified
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   538
     * using a comma separated list.  Service providers are loaded after the AWT
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   539
     * toolkit is created. All errors are handled via an AWTError exception.
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   540
     * <p>
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   541
     * The names specified in the assistive_technologies property are used to query
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   542
     * each service provider implementation.  If the requested name matches the
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   543
     * {@linkplain AccessibilityProvider#getName name} of the service provider, the
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   544
     * {@link AccessibilityProvider#activate} method will be invoked to activate the
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   545
     * matching service provider.
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   546
     *
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   547
     * @implSpec
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   548
     * If assistive technology service providers are not specified with a system
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   549
     * property this implementation will look in a properties file located as follows:
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   550
     * <ul>
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   551
     * <li> {@code ${user.home}/.accessibility.properties}
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   552
     * <li> {@code ${java.home}/conf/accessibility.properties}
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   553
     * </ul>
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   554
     * Only the first of these files to be located will be consulted.  The requested
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   555
     * service providers are specified by setting the {@code assistive_technologies=}
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   556
     * property.  A single provider or a comma separated list of providers can be
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   557
     * specified.
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   558
     *
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   559
     * @return     the default toolkit.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
     * @exception  AWTError  if a toolkit could not be found, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
     *                 if one could not be accessed or instantiated.
31438
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   562
     * @see java.util.ServiceLoader
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   563
     * @see javax.accessibility.AccessibilityProvider
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
    public static synchronized Toolkit getDefaultToolkit() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
        if (toolkit == null) {
23317
73a0f3327dcc 6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents: 22282
diff changeset
   567
            java.security.AccessController.doPrivileged(
73a0f3327dcc 6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents: 22282
diff changeset
   568
                    new java.security.PrivilegedAction<Void>() {
73a0f3327dcc 6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents: 22282
diff changeset
   569
                public Void run() {
73a0f3327dcc 6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents: 22282
diff changeset
   570
                    Class<?> cls = null;
73a0f3327dcc 6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents: 22282
diff changeset
   571
                    String nm = System.getProperty("awt.toolkit");
73a0f3327dcc 6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents: 22282
diff changeset
   572
                    try {
73a0f3327dcc 6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents: 22282
diff changeset
   573
                        cls = Class.forName(nm);
73a0f3327dcc 6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents: 22282
diff changeset
   574
                    } catch (ClassNotFoundException e) {
73a0f3327dcc 6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents: 22282
diff changeset
   575
                        ClassLoader cl = ClassLoader.getSystemClassLoader();
73a0f3327dcc 6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents: 22282
diff changeset
   576
                        if (cl != null) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
                            try {
23317
73a0f3327dcc 6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents: 22282
diff changeset
   578
                                cls = cl.loadClass(nm);
73a0f3327dcc 6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents: 22282
diff changeset
   579
                            } catch (final ClassNotFoundException ignored) {
73a0f3327dcc 6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents: 22282
diff changeset
   580
                                throw new AWTError("Toolkit not found: " + nm);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
                            }
23317
73a0f3327dcc 6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents: 22282
diff changeset
   582
                        }
73a0f3327dcc 6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents: 22282
diff changeset
   583
                    }
73a0f3327dcc 6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents: 22282
diff changeset
   584
                    try {
73a0f3327dcc 6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents: 22282
diff changeset
   585
                        if (cls != null) {
73a0f3327dcc 6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents: 22282
diff changeset
   586
                            toolkit = (Toolkit)cls.newInstance();
73a0f3327dcc 6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents: 22282
diff changeset
   587
                            if (GraphicsEnvironment.isHeadless()) {
73a0f3327dcc 6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents: 22282
diff changeset
   588
                                toolkit = new HeadlessToolkit(toolkit);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
                        }
23317
73a0f3327dcc 6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents: 22282
diff changeset
   591
                    } catch (final InstantiationException ignored) {
73a0f3327dcc 6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents: 22282
diff changeset
   592
                        throw new AWTError("Could not instantiate Toolkit: " + nm);
73a0f3327dcc 6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents: 22282
diff changeset
   593
                    } catch (final IllegalAccessException ignored) {
73a0f3327dcc 6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents: 22282
diff changeset
   594
                        throw new AWTError("Could not access Toolkit: " + nm);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
                    }
23317
73a0f3327dcc 6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents: 22282
diff changeset
   596
                    return null;
73a0f3327dcc 6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents: 22282
diff changeset
   597
                }
73a0f3327dcc 6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
serb
parents: 22282
diff changeset
   598
            });
31438
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   599
            if (!GraphicsEnvironment.isHeadless()) {
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   600
                loadAssistiveTechnologies();
5593480edd2a 8055160: Support loading of Assistive Technology from service provider
ptbrunet
parents: 30471
diff changeset
   601
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
        return toolkit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
     * Returns an image which gets pixel data from the specified file,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
     * whose format can be either GIF, JPEG or PNG.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
     * The underlying toolkit attempts to resolve multiple requests
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
     * with the same filename to the same returned Image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
     * Since the mechanism required to facilitate this sharing of
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   613
     * {@code Image} objects may continue to hold onto images
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
     * that are no longer in use for an indefinite period of time,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
     * developers are encouraged to implement their own caching of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
     * images by using the {@link #createImage(java.lang.String) createImage}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
     * variant wherever available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
     * If the image data contained in the specified file changes,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   619
     * the {@code Image} object returned from this method may
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
     * still contain stale information which was loaded from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
     * file after a prior call.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
     * Previously loaded image data can be manually discarded by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
     * calling the {@link Image#flush flush} method on the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   624
     * returned {@code Image}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
     * This method first checks if there is a security manager installed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
     * If so, the method calls the security manager's
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   628
     * {@code checkRead} method with the file specified to ensure
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
     * that the access to the image is allowed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
     * @param     filename   the name of a file containing pixel data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
     *                         in a recognized file format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
     * @return    an image which gets its pixel data from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
     *                         the specified file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
     * @throws SecurityException  if a security manager exists and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
     *                            checkRead method doesn't allow the operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
     * @see #createImage(java.lang.String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
    public abstract Image getImage(String filename);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
     * Returns an image which gets pixel data from the specified URL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
     * The pixel data referenced by the specified URL must be in one
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
     * of the following formats: GIF, JPEG or PNG.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
     * The underlying toolkit attempts to resolve multiple requests
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
     * with the same URL to the same returned Image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
     * Since the mechanism required to facilitate this sharing of
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   648
     * {@code Image} objects may continue to hold onto images
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
     * that are no longer in use for an indefinite period of time,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
     * developers are encouraged to implement their own caching of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
     * images by using the {@link #createImage(java.net.URL) createImage}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
     * variant wherever available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
     * If the image data stored at the specified URL changes,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   654
     * the {@code Image} object returned from this method may
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
     * still contain stale information which was fetched from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
     * URL after a prior call.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
     * Previously loaded image data can be manually discarded by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
     * calling the {@link Image#flush flush} method on the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   659
     * returned {@code Image}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
     * This method first checks if there is a security manager installed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
     * If so, the method calls the security manager's
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   663
     * {@code checkPermission} method with the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
     * url.openConnection().getPermission() permission to ensure
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
     * that the access to the image is allowed. For compatibility
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
     * with pre-1.2 security managers, if the access is denied with
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   667
     * {@code FilePermission} or {@code SocketPermission},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   668
     * the method throws the {@code SecurityException}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
     * if the corresponding 1.1-style SecurityManager.checkXXX method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
     * also denies permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
     * @param     url   the URL to use in fetching the pixel data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
     * @return    an image which gets its pixel data from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
     *                         the specified URL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
     * @throws SecurityException  if a security manager exists and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
     *                            checkPermission method doesn't allow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
     *                            the operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
     * @see #createImage(java.net.URL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
    public abstract Image getImage(URL url);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
     * Returns an image which gets pixel data from the specified file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
     * The returned Image is a new object which will not be shared
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
     * with any other caller of this method or its getImage variant.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
     * This method first checks if there is a security manager installed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
     * If so, the method calls the security manager's
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   688
     * {@code checkRead} method with the specified file to ensure
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
     * that the image creation is allowed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
     * @param     filename   the name of a file containing pixel data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
     *                         in a recognized file format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
     * @return    an image which gets its pixel data from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
     *                         the specified file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
     * @throws SecurityException  if a security manager exists and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
     *                            checkRead method doesn't allow the operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
     * @see #getImage(java.lang.String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
    public abstract Image createImage(String filename);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
     * Returns an image which gets pixel data from the specified URL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
     * The returned Image is a new object which will not be shared
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
     * with any other caller of this method or its getImage variant.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
     * This method first checks if there is a security manager installed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
     * If so, the method calls the security manager's
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   707
     * {@code checkPermission} method with the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
     * url.openConnection().getPermission() permission to ensure
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
     * that the image creation is allowed. For compatibility
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
     * with pre-1.2 security managers, if the access is denied with
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   711
     * {@code FilePermission} or {@code SocketPermission},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   712
     * the method throws {@code SecurityException}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
     * if the corresponding 1.1-style SecurityManager.checkXXX method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
     * also denies permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
     * @param     url   the URL to use in fetching the pixel data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
     * @return    an image which gets its pixel data from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
     *                         the specified URL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
     * @throws SecurityException  if a security manager exists and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
     *                            checkPermission method doesn't allow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
     *                            the operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
     * @see #getImage(java.net.URL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
    public abstract Image createImage(URL url);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
     * Prepares an image for rendering.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
     * If the values of the width and height arguments are both
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   729
     * {@code -1}, this method prepares the image for rendering
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
     * on the default screen; otherwise, this method prepares an image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
     * for rendering on the default screen at the specified width and height.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
     * The image data is downloaded asynchronously in another thread,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
     * and an appropriately scaled screen representation of the image is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
     * generated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   737
     * This method is called by components {@code prepareImage}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
     * methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
     * Information on the flags returned by this method can be found
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   741
     * with the definition of the {@code ImageObserver} interface.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
     * @param     image      the image for which to prepare a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
     *                           screen representation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
     * @param     width      the width of the desired screen
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   746
     *                           representation, or {@code -1}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
     * @param     height     the height of the desired screen
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   748
     *                           representation, or {@code -1}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   749
     * @param     observer   the {@code ImageObserver}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
     *                           object to be notified as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
     *                           image is being prepared.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   752
     * @return    {@code true} if the image has already been
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   753
     *                 fully prepared; {@code false} otherwise.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
     * @see       java.awt.Component#prepareImage(java.awt.Image,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
     *                 java.awt.image.ImageObserver)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
     * @see       java.awt.Component#prepareImage(java.awt.Image,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
     *                 int, int, java.awt.image.ImageObserver)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
     * @see       java.awt.image.ImageObserver
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
    public abstract boolean prepareImage(Image image, int width, int height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
                                         ImageObserver observer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
     * Indicates the construction status of a specified image that is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
     * being prepared for display.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
     * If the values of the width and height arguments are both
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   768
     * {@code -1}, this method returns the construction status of
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
     * a screen representation of the specified image in this toolkit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
     * Otherwise, this method returns the construction status of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
     * scaled representation of the image at the specified width
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
     * and height.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
     * This method does not cause the image to begin loading.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   775
     * An application must call {@code prepareImage} to force
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
     * the loading of an image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   778
     * This method is called by the component's {@code checkImage}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
     * methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
     * Information on the flags returned by this method can be found
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   782
     * with the definition of the {@code ImageObserver} interface.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
     * @param     image   the image whose status is being checked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
     * @param     width   the width of the scaled version whose status is
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   785
     *                 being checked, or {@code -1}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
     * @param     height  the height of the scaled version whose status
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   787
     *                 is being checked, or {@code -1}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   788
     * @param     observer   the {@code ImageObserver} object to be
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
     *                 notified as the image is being prepared.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
     * @return    the bitwise inclusive <strong>OR</strong> of the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   791
     *                 {@code ImageObserver} flags for the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
     *                 image data that is currently available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
     * @see       java.awt.Toolkit#prepareImage(java.awt.Image,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
     *                 int, int, java.awt.image.ImageObserver)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
     * @see       java.awt.Component#checkImage(java.awt.Image,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
     *                 java.awt.image.ImageObserver)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
     * @see       java.awt.Component#checkImage(java.awt.Image,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
     *                 int, int, java.awt.image.ImageObserver)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
     * @see       java.awt.image.ImageObserver
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
    public abstract int checkImage(Image image, int width, int height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
                                   ImageObserver observer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
     * Creates an image with the specified image producer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
     * @param     producer the image producer to be used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
     * @return    an image with the specified image producer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
     * @see       java.awt.Image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
     * @see       java.awt.image.ImageProducer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
     * @see       java.awt.Component#createImage(java.awt.image.ImageProducer)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
    public abstract Image createImage(ImageProducer producer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
     * Creates an image which decodes the image stored in the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
     * byte array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
     * The data must be in some image format, such as GIF or JPEG,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
     * that is supported by this toolkit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
     * @param     imagedata   an array of bytes, representing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
     *                         image data in a supported image format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
     * @return    an image.
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23717
diff changeset
   823
     * @since     1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
    public Image createImage(byte[] imagedata) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
        return createImage(imagedata, 0, imagedata.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
     * Creates an image which decodes the image stored in the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
     * byte array, and at the specified offset and length.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
     * The data must be in some image format, such as GIF or JPEG,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
     * that is supported by this toolkit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
     * @param     imagedata   an array of bytes, representing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
     *                         image data in a supported image format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
     * @param     imageoffset  the offset of the beginning
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
     *                         of the data in the array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
     * @param     imagelength  the length of the data in the array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
     * @return    an image.
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23717
diff changeset
   840
     * @since     1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
    public abstract Image createImage(byte[] imagedata,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
                                      int imageoffset,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
                                      int imagelength);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   847
     * Gets a {@code PrintJob} object which is the result of initiating
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
     * a print operation on the toolkit's platform.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
     * Each actual implementation of this method should first check if there
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
     * is a security manager installed. If there is, the method should call
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   852
     * the security manager's {@code checkPrintJobAccess} method to
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
     * ensure initiation of a print operation is allowed. If the default
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   854
     * implementation of {@code checkPrintJobAccess} is used (that is,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
     * that method is not overriden), then this results in a call to the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   856
     * security manager's {@code checkPermission} method with a
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   857
     * {@code RuntimePermission("queuePrintJob")} permission.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
     * @param   frame the parent of the print dialog. May not be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
     * @param   jobtitle the title of the PrintJob. A null title is equivalent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
     *          to "".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
     * @param   props a Properties object containing zero or more properties.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
     *          Properties are not standardized and are not consistent across
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
     *          implementations. Because of this, PrintJobs which require job
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
     *          and page control should use the version of this function which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
     *          takes JobAttributes and PageAttributes objects. This object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
     *          may be updated to reflect the user's job choices on exit. May
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
     *          be null.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   869
     * @return  a {@code PrintJob} object, or {@code null} if the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
     *          user cancelled the print job.
8947
35ff89272f4f 7023011: Toolkit.getPrintJob(Frame,String,Properties) throws HE instead of specified NPE
dav
parents: 7668
diff changeset
   871
     * @throws  NullPointerException if frame is null
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
     * @throws  SecurityException if this thread is not allowed to initiate a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
     *          print job request
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
     * @see     java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
     * @see     java.awt.PrintJob
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
     * @see     java.lang.RuntimePermission
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23717
diff changeset
   877
     * @since   1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
    public abstract PrintJob getPrintJob(Frame frame, String jobtitle,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
                                         Properties props);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   883
     * Gets a {@code PrintJob} object which is the result of initiating
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
     * a print operation on the toolkit's platform.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
     * Each actual implementation of this method should first check if there
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
     * is a security manager installed. If there is, the method should call
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   888
     * the security manager's {@code checkPrintJobAccess} method to
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
     * ensure initiation of a print operation is allowed. If the default
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   890
     * implementation of {@code checkPrintJobAccess} is used (that is,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
     * that method is not overriden), then this results in a call to the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   892
     * security manager's {@code checkPermission} method with a
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   893
     * {@code RuntimePermission("queuePrintJob")} permission.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
     *
9661
d837c8c8ac46 7042537: When press the 'Print' button,the NullPointerException is thrown and printdialog is not pop up.
dav
parents: 9656
diff changeset
   895
     * @param   frame the parent of the print dialog. May not be null.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
     * @param   jobtitle the title of the PrintJob. A null title is equivalent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
     *          to "".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
     * @param   jobAttributes a set of job attributes which will control the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
     *          PrintJob. The attributes will be updated to reflect the user's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
     *          choices as outlined in the JobAttributes documentation. May be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
     *          null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
     * @param   pageAttributes a set of page attributes which will control the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
     *          PrintJob. The attributes will be applied to every page in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
     *          job. The attributes will be updated to reflect the user's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
     *          choices as outlined in the PageAttributes documentation. May be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
     *          null.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   907
     * @return  a {@code PrintJob} object, or {@code null} if the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
     *          user cancelled the print job.
8947
35ff89272f4f 7023011: Toolkit.getPrintJob(Frame,String,Properties) throws HE instead of specified NPE
dav
parents: 7668
diff changeset
   909
     * @throws  NullPointerException if frame is null
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
     * @throws  IllegalArgumentException if pageAttributes specifies differing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
     *          cross feed and feed resolutions. Also if this thread has
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
     *          access to the file system and jobAttributes specifies
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
     *          print to file, and the specified destination file exists but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
     *          is a directory rather than a regular file, does not exist but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
     *          cannot be created, or cannot be opened for any other reason.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
     *          However in the case of print to file, if a dialog is also
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
     *          requested to be displayed then the user will be given an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
     *          opportunity to select a file and proceed with printing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
     *          The dialog will ensure that the selected output file
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
     *          is valid before returning from this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
     * @throws  SecurityException if this thread is not allowed to initiate a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
     *          print job request, or if jobAttributes specifies print to file,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
     *          and this thread is not allowed to access the file system
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
     * @see     java.awt.PrintJob
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
     * @see     java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
     * @see     java.lang.RuntimePermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
     * @see     java.awt.JobAttributes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
     * @see     java.awt.PageAttributes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
     * @since   1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
    public PrintJob getPrintJob(Frame frame, String jobtitle,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
                                JobAttributes jobAttributes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
                                PageAttributes pageAttributes) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
        // Override to add printing support with new job/page control classes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
        if (this != Toolkit.getDefaultToolkit()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
            return Toolkit.getDefaultToolkit().getPrintJob(frame, jobtitle,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
                                                           jobAttributes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
                                                           pageAttributes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
            return getPrintJob(frame, jobtitle, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
    /**
20123
e12d9acdc289 8003965: Toolkit.beep() documentation is ambiguous
bagiras
parents: 18275
diff changeset
   946
     * Emits an audio beep depending on native system settings and hardware
e12d9acdc289 8003965: Toolkit.beep() documentation is ambiguous
bagiras
parents: 18275
diff changeset
   947
     * capabilities.
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23717
diff changeset
   948
     * @since     1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
    public abstract void beep();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
     * Gets the singleton instance of the system Clipboard which interfaces
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
     * with clipboard facilities provided by the native platform. This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
     * clipboard enables data transfer between Java programs and native
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
     * applications which use native clipboard facilities.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
     * <p>
25782
5a832643a534 8047336: Read flavormap.properties as resource
pchelko
parents: 25162
diff changeset
   958
     * In addition to any and all default formats text returned by the system
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   959
     * Clipboard's {@code getTransferData()} method is available in the
25782
5a832643a534 8047336: Read flavormap.properties as resource
pchelko
parents: 25162
diff changeset
   960
     * following flavors:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
     * <li>DataFlavor.stringFlavor</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
     * <li>DataFlavor.plainTextFlavor (<b>deprecated</b>)</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
     * </ul>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   965
     * As with {@code java.awt.datatransfer.StringSelection}, if the
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   966
     * requested flavor is {@code DataFlavor.plainTextFlavor}, or an
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
     * equivalent flavor, a Reader is returned. <b>Note:</b> The behavior of
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   968
     * the system Clipboard's {@code getTransferData()} method for
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   969
     * {@code DataFlavor.plainTextFlavor}, and equivalent DataFlavors, is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   970
     * inconsistent with the definition of {@code DataFlavor.plainTextFlavor}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   971
     * Because of this, support for
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   972
     * {@code DataFlavor.plainTextFlavor}, and equivalent flavors, is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
     * <b>deprecated</b>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
     * Each actual implementation of this method should first check if there
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
     * is a security manager installed. If there is, the method should call
19807
9f7860fad128 8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents: 18275
diff changeset
   977
     * the security manager's {@link SecurityManager#checkPermission
9f7860fad128 8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents: 18275
diff changeset
   978
     * checkPermission} method to check {@code AWTPermission("accessClipboard")}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
     * @return    the system Clipboard
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
     * @see       java.awt.datatransfer.Clipboard
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
     * @see       java.awt.datatransfer.StringSelection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
     * @see       java.awt.datatransfer.DataFlavor#stringFlavor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
     * @see       java.awt.datatransfer.DataFlavor#plainTextFlavor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
     * @see       java.io.Reader
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
     * @see       java.awt.AWTPermission
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23717
diff changeset
   990
     * @since     1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
    public abstract Clipboard getSystemClipboard()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
        throws HeadlessException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
     * Gets the singleton instance of the system selection as a
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   997
     * {@code Clipboard} object. This allows an application to read and
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
     * modify the current, system-wide selection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
     * An application is responsible for updating the system selection whenever
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
     * the user selects text, using either the mouse or the keyboard.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
     * Typically, this is implemented by installing a
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1003
     * {@code FocusListener} on all {@code Component}s which support
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1004
     * text selection, and, between {@code FOCUS_GAINED} and
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1005
     * {@code FOCUS_LOST} events delivered to that {@code Component},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1006
     * updating the system selection {@code Clipboard} when the selection
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1007
     * changes inside the {@code Component}. Properly updating the system
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
     * selection ensures that a Java application will interact correctly with
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
     * native applications and other Java applications running simultaneously
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1010
     * on the system. Note that {@code java.awt.TextComponent} and
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1011
     * {@code javax.swing.text.JTextComponent} already adhere to this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
     * policy. When using these classes, and their subclasses, developers need
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
     * not write any additional code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1015
     * Some platforms do not support a system selection {@code Clipboard}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1016
     * On those platforms, this method will return {@code null}. In such a
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
     * case, an application is absolved from its responsibility to update the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1018
     * system selection {@code Clipboard} as described above.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
     * Each actual implementation of this method should first check if there
19807
9f7860fad128 8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents: 18275
diff changeset
  1021
     * is a security manager installed. If there is, the method should call
9f7860fad128 8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents: 18275
diff changeset
  1022
     * the security manager's {@link SecurityManager#checkPermission
9f7860fad128 8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents: 18275
diff changeset
  1023
     * checkPermission} method to check {@code AWTPermission("accessClipboard")}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1025
     * @return the system selection as a {@code Clipboard}, or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1026
     *         {@code null} if the native platform does not support a
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1027
     *         system selection {@code Clipboard}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
     *            returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
     * @see java.awt.datatransfer.Clipboard
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
     * @see java.awt.event.FocusListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
     * @see java.awt.event.FocusEvent#FOCUS_GAINED
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
     * @see java.awt.event.FocusEvent#FOCUS_LOST
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
     * @see TextComponent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
     * @see javax.swing.text.JTextComponent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
     * @see AWTPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
     * @see GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
    public Clipboard getSystemSelection() throws HeadlessException {
9656
b9011986e4c8 7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents: 9475
diff changeset
  1042
        GraphicsEnvironment.checkHeadless();
b9011986e4c8 7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents: 9475
diff changeset
  1043
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
        if (this != Toolkit.getDefaultToolkit()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
            return Toolkit.getDefaultToolkit().getSystemSelection();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
            GraphicsEnvironment.checkHeadless();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
     * Determines which modifier key is the appropriate accelerator
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
     * key for menu shortcuts.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
     * Menu shortcuts, which are embodied in the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1057
     * {@code MenuShortcut} class, are handled by the
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1058
     * {@code MenuBar} class.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1060
     * By default, this method returns {@code Event.CTRL_MASK}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
     * Toolkit implementations should override this method if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
     * <b>Control</b> key isn't the correct key for accelerators.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1063
     * @return    the modifier mask on the {@code Event} class
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
     *                 that is used for menu shortcuts on this toolkit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
     * @see       java.awt.MenuBar
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
     * @see       java.awt.MenuShortcut
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23717
diff changeset
  1070
     * @since     1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
    public int getMenuShortcutKeyMask() throws HeadlessException {
9656
b9011986e4c8 7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents: 9475
diff changeset
  1073
        GraphicsEnvironment.checkHeadless();
9207
e0233c19a2c0 7021001: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
denis
parents: 9206
diff changeset
  1074
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
        return Event.CTRL_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
     * Returns whether the given locking key on the keyboard is currently in
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
     * its "on" state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
     * Valid key codes are
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
     * {@link java.awt.event.KeyEvent#VK_CAPS_LOCK VK_CAPS_LOCK},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
     * {@link java.awt.event.KeyEvent#VK_NUM_LOCK VK_NUM_LOCK},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
     * {@link java.awt.event.KeyEvent#VK_SCROLL_LOCK VK_SCROLL_LOCK}, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
     * {@link java.awt.event.KeyEvent#VK_KANA_LOCK VK_KANA_LOCK}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
     *
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1087
     * @param  keyCode the key code
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1088
     * @return {@code true} if the given key is currently in its "on" state;
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1089
     *          otherwise {@code false}
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1090
     * @exception java.lang.IllegalArgumentException if {@code keyCode}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
     * is not one of the valid key codes
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
     * @exception java.lang.UnsupportedOperationException if the host system doesn't
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
     * allow getting the state of this key programmatically, or if the keyboard
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
     * doesn't have this key
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
    public boolean getLockingKeyState(int keyCode)
9656
b9011986e4c8 7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents: 9475
diff changeset
  1101
        throws UnsupportedOperationException
b9011986e4c8 7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents: 9475
diff changeset
  1102
    {
b9011986e4c8 7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents: 9475
diff changeset
  1103
        GraphicsEnvironment.checkHeadless();
b9011986e4c8 7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents: 9475
diff changeset
  1104
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
        if (! (keyCode == KeyEvent.VK_CAPS_LOCK || keyCode == KeyEvent.VK_NUM_LOCK ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
               keyCode == KeyEvent.VK_SCROLL_LOCK || keyCode == KeyEvent.VK_KANA_LOCK)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
            throw new IllegalArgumentException("invalid key for Toolkit.getLockingKeyState");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
        throw new UnsupportedOperationException("Toolkit.getLockingKeyState");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
     * Sets the state of the given locking key on the keyboard.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
     * Valid key codes are
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
     * {@link java.awt.event.KeyEvent#VK_CAPS_LOCK VK_CAPS_LOCK},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
     * {@link java.awt.event.KeyEvent#VK_NUM_LOCK VK_NUM_LOCK},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
     * {@link java.awt.event.KeyEvent#VK_SCROLL_LOCK VK_SCROLL_LOCK}, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
     * {@link java.awt.event.KeyEvent#VK_KANA_LOCK VK_KANA_LOCK}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
     * Depending on the platform, setting the state of a locking key may
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
     * involve event processing and therefore may not be immediately
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
     * observable through getLockingKeyState.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
     *
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1124
     * @param  keyCode the key code
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1125
     * @param  on the state of the key
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1126
     * @exception java.lang.IllegalArgumentException if {@code keyCode}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
     * is not one of the valid key codes
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
     * @exception java.lang.UnsupportedOperationException if the host system doesn't
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
     * allow setting the state of this key programmatically, or if the keyboard
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
     * doesn't have this key
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
    public void setLockingKeyState(int keyCode, boolean on)
9656
b9011986e4c8 7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents: 9475
diff changeset
  1137
        throws UnsupportedOperationException
b9011986e4c8 7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents: 9475
diff changeset
  1138
    {
b9011986e4c8 7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents: 9475
diff changeset
  1139
        GraphicsEnvironment.checkHeadless();
b9011986e4c8 7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents: 9475
diff changeset
  1140
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
        if (! (keyCode == KeyEvent.VK_CAPS_LOCK || keyCode == KeyEvent.VK_NUM_LOCK ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
               keyCode == KeyEvent.VK_SCROLL_LOCK || keyCode == KeyEvent.VK_KANA_LOCK)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
            throw new IllegalArgumentException("invalid key for Toolkit.setLockingKeyState");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
        throw new UnsupportedOperationException("Toolkit.setLockingKeyState");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
     * Give native peers the ability to query the native container
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
     * given a native component (eg the direct parent may be lightweight).
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1151
     *
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1152
     * @param  c the component to fetch the container for
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1153
     * @return the native container object for the component
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
    protected static Container getNativeContainer(Component c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
        return c.getNativeContainer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
     * Creates a new custom cursor object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
     * If the image to display is invalid, the cursor will be hidden (made
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
     * completely transparent), and the hotspot will be set to (0, 0).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
     * <p>Note that multi-frame images are invalid and may cause this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
     * method to hang.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
     *
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 21275
diff changeset
  1167
     * @param cursor the image to display when the cursor is activated
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
     * @param hotSpot the X and Y of the large cursor's hot spot; the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
     *   hotSpot values must be less than the Dimension returned by
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1170
     *   {@code getBestCursorSize}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
     * @param     name a localized description of the cursor, for Java Accessibility use
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
     * @exception IndexOutOfBoundsException if the hotSpot values are outside
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
     *   the bounds of the cursor
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1174
     * @return the cursor created
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
     * @since     1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
    public Cursor createCustomCursor(Image cursor, Point hotSpot, String name)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
        throws IndexOutOfBoundsException, HeadlessException
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
        // Override to implement custom cursor support.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
        if (this != Toolkit.getDefaultToolkit()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
            return Toolkit.getDefaultToolkit().
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
                createCustomCursor(cursor, hotSpot, name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
            return new Cursor(Cursor.DEFAULT_CURSOR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
     * Returns the supported cursor dimension which is closest to the desired
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
     * sizes.  Systems which only support a single cursor size will return that
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
     * size regardless of the desired sizes.  Systems which don't support custom
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
     * cursors will return a dimension of 0, 0. <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
     * Note:  if an image is used whose dimensions don't match a supported size
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
     * (as returned by this method), the Toolkit implementation will attempt to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
     * resize the image to a supported size.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
     * Since converting low-resolution images is difficult,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
     * no guarantees are made as to the quality of a cursor image which isn't a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
     * supported size.  It is therefore recommended that this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
     * be called and an appropriate image used so no image conversion is made.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
     * @param     preferredWidth the preferred cursor width the component would like
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
     * to use.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
     * @param     preferredHeight the preferred cursor height the component would like
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
     * to use.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
     * @return    the closest matching supported cursor size, or a dimension of 0,0 if
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
     * the Toolkit implementation doesn't support custom cursors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
     * @since     1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
    public Dimension getBestCursorSize(int preferredWidth,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
        int preferredHeight) throws HeadlessException {
9656
b9011986e4c8 7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents: 9475
diff changeset
  1218
        GraphicsEnvironment.checkHeadless();
b9011986e4c8 7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents: 9475
diff changeset
  1219
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
        // Override to implement custom cursor support.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
        if (this != Toolkit.getDefaultToolkit()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
            return Toolkit.getDefaultToolkit().
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
                getBestCursorSize(preferredWidth, preferredHeight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
            return new Dimension(0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
     * Returns the maximum number of colors the Toolkit supports in a custom cursor
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
     * palette.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
     * Note: if an image is used which has more colors in its palette than
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
     * the supported maximum, the Toolkit implementation will attempt to flatten the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
     * palette to the maximum.  Since converting low-resolution images is difficult,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
     * no guarantees are made as to the quality of a cursor image which has more
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
     * colors than the system supports.  It is therefore recommended that this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
     * be called and an appropriate image used so no image conversion is made.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
     * @return    the maximum number of colors, or zero if custom cursors are not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
     * supported by this Toolkit implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
     * returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
     * @since     1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
    public int getMaximumCursorColors() throws HeadlessException {
9656
b9011986e4c8 7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents: 9475
diff changeset
  1247
        GraphicsEnvironment.checkHeadless();
b9011986e4c8 7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents: 9475
diff changeset
  1248
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
        // Override to implement custom cursor support.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
        if (this != Toolkit.getDefaultToolkit()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
            return Toolkit.getDefaultToolkit().getMaximumCursorColors();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
            return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1254
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1257
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1258
     * Returns whether Toolkit supports this state for
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1259
     * {@code Frame}s.  This method tells whether the <em>UI
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
     * concept</em> of, say, maximization or iconification is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1261
     * supported.  It will always return false for "compound" states
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1262
     * like {@code Frame.ICONIFIED|Frame.MAXIMIZED_VERT}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1263
     * In other words, the rule of thumb is that only queries with a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1264
     * single frame state constant as an argument are meaningful.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1265
     * <p>Note that supporting a given concept is a platform-
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1266
     * dependent feature. Due to native limitations the Toolkit
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1267
     * object may report a particular state as supported, however at
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1268
     * the same time the Toolkit object will be unable to apply the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1269
     * state to a given frame.  This circumstance has two following
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1270
     * consequences:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1271
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1272
     * <li>Only the return value of {@code false} for the present
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1273
     * method actually indicates that the given state is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1274
     * supported. If the method returns {@code true} the given state
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1275
     * may still be unsupported and/or unavailable for a particular
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1276
     * frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1277
     * <li>The developer should consider examining the value of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1278
     * {@link java.awt.event.WindowEvent#getNewState} method of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
     * {@code WindowEvent} received through the {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1280
     * java.awt.event.WindowStateListener}, rather than assuming
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
     * that the state given to the {@code setExtendedState()} method
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
     * will be definitely applied. For more information see the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1283
     * documentation for the {@link Frame#setExtendedState} method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1284
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1285
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1286
     * @param state one of named frame state constants.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1287
     * @return {@code true} is this frame state is supported by
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1288
     *     this Toolkit implementation, {@code false} otherwise.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1289
     * @exception HeadlessException
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1290
     *     if {@code GraphicsEnvironment.isHeadless()}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1291
     *     returns {@code true}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1292
     * @see java.awt.Window#addWindowStateListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
     * @since   1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1294
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1295
    public boolean isFrameStateSupported(int state)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1296
        throws HeadlessException
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1297
    {
9656
b9011986e4c8 7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents: 9475
diff changeset
  1298
        GraphicsEnvironment.checkHeadless();
b9011986e4c8 7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents: 9475
diff changeset
  1299
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1300
        if (this != Toolkit.getDefaultToolkit()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1301
            return Toolkit.getDefaultToolkit().
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1302
                isFrameStateSupported(state);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1303
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1304
            return (state == Frame.NORMAL); // others are not guaranteed
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1305
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1306
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1307
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1308
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1309
     * Support for I18N: any visible strings should be stored in
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1310
     * sun.awt.resources.awt.properties.  The ResourceBundle is stored
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1311
     * here, so that only one copy is maintained.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1312
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1313
    private static ResourceBundle resources;
20147
78e51d8fcb92 7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents: 20145
diff changeset
  1314
    private static ResourceBundle platformResources;
78e51d8fcb92 7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents: 20145
diff changeset
  1315
78e51d8fcb92 7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents: 20145
diff changeset
  1316
    // called by platform toolkit
78e51d8fcb92 7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents: 20145
diff changeset
  1317
    private static void setPlatformResources(ResourceBundle bundle) {
78e51d8fcb92 7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents: 20145
diff changeset
  1318
        platformResources = bundle;
78e51d8fcb92 7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents: 20145
diff changeset
  1319
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1320
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1321
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1322
     * Initialize JNI field and method ids
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1323
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1324
    private static native void initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1325
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1326
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1327
     * WARNING: This is a temporary workaround for a problem in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1328
     * way the AWT loads native libraries. A number of classes in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1329
     * AWT package have a native method, initIDs(), which initializes
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1330
     * the JNI field and method ids used in the native portion of
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1331
     * their implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1332
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1333
     * Since the use and storage of these ids is done by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1334
     * implementation libraries, the implementation of these method is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1335
     * provided by the particular AWT implementations (for example,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1336
     * "Toolkit"s/Peer), such as Motif, Microsoft Windows, or Tiny. The
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1337
     * problem is that this means that the native libraries must be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1338
     * loaded by the java.* classes, which do not necessarily know the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1339
     * names of the libraries to load. A better way of doing this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1340
     * would be to provide a separate library which defines java.awt.*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1341
     * initIDs, and exports the relevant symbols out to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1342
     * implementation libraries.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1343
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1344
     * For now, we know it's done by the implementation, and we assume
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1345
     * that the name of the library is "awt".  -br.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1346
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1347
     * If you change loadLibraries(), please add the change to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1348
     * java.awt.image.ColorModel.loadLibraries(). Unfortunately,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1349
     * classes can be loaded in java.awt.image that depend on
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1350
     * libawt and there is no way to call Toolkit.loadLibraries()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1351
     * directly.  -hung
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1352
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1353
    private static boolean loaded = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1354
    static void loadLibraries() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1355
        if (!loaded) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1356
            java.security.AccessController.doPrivileged(
12559
9456ceada8b1 7164376: Replace use of sun.security.action.LoadLibraryAction with System.loadLibrary
mchung
parents: 11270
diff changeset
  1357
                new java.security.PrivilegedAction<Void>() {
9456ceada8b1 7164376: Replace use of sun.security.action.LoadLibraryAction with System.loadLibrary
mchung
parents: 11270
diff changeset
  1358
                    public Void run() {
9456ceada8b1 7164376: Replace use of sun.security.action.LoadLibraryAction with System.loadLibrary
mchung
parents: 11270
diff changeset
  1359
                        System.loadLibrary("awt");
9456ceada8b1 7164376: Replace use of sun.security.action.LoadLibraryAction with System.loadLibrary
mchung
parents: 11270
diff changeset
  1360
                        return null;
9456ceada8b1 7164376: Replace use of sun.security.action.LoadLibraryAction with System.loadLibrary
mchung
parents: 11270
diff changeset
  1361
                    }
9456ceada8b1 7164376: Replace use of sun.security.action.LoadLibraryAction with System.loadLibrary
mchung
parents: 11270
diff changeset
  1362
                });
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1363
            loaded = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1364
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1365
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1366
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1367
    static {
20147
78e51d8fcb92 7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents: 20145
diff changeset
  1368
        AWTAccessor.setToolkitAccessor(
78e51d8fcb92 7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents: 20145
diff changeset
  1369
                new AWTAccessor.ToolkitAccessor() {
78e51d8fcb92 7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents: 20145
diff changeset
  1370
                    @Override
78e51d8fcb92 7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents: 20145
diff changeset
  1371
                    public void setPlatformResources(ResourceBundle bundle) {
78e51d8fcb92 7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents: 20145
diff changeset
  1372
                        Toolkit.setPlatformResources(bundle);
78e51d8fcb92 7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents: 20145
diff changeset
  1373
                    }
78e51d8fcb92 7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents: 20145
diff changeset
  1374
                });
78e51d8fcb92 7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents: 20145
diff changeset
  1375
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1376
        java.security.AccessController.doPrivileged(
11270
d7b0b63bd082 7117334: Warnings cleanup day: reduce number of javac warnings in the java.awt package
bagiras
parents: 10068
diff changeset
  1377
                                 new java.security.PrivilegedAction<Void>() {
d7b0b63bd082 7117334: Warnings cleanup day: reduce number of javac warnings in the java.awt package
bagiras
parents: 10068
diff changeset
  1378
            public Void run() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1379
                try {
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
  1380
                    resources = ResourceBundle.getBundle("sun.awt.resources.awt");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1381
                } catch (MissingResourceException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1382
                    // No resource file; defaults will be used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1383
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1384
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1385
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1386
        });
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1387
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1388
        // ensure that the proper libraries are loaded
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1389
        loadLibraries();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1390
        initAssistiveTechnologies();
39863
bd45c335847b 8159956: EXCEPTION_ACCESS_VIOLATION in sun.awt.windows.ThemeReader.getThemeMargins
aghaisas
parents: 38396
diff changeset
  1391
        initIDs();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1392
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1393
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1394
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1395
     * Gets a property with the specified key and default.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1396
     * This method returns defaultValue if the property is not found.
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1397
     *
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1398
     * @param  key the key
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1399
     * @param  defaultValue the default value
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1400
     * @return the value of the property or the default value
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1401
     *         if the property was not found
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1402
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1403
    public static String getProperty(String key, String defaultValue) {
20147
78e51d8fcb92 7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents: 20145
diff changeset
  1404
        // first try platform specific bundle
78e51d8fcb92 7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents: 20145
diff changeset
  1405
        if (platformResources != null) {
78e51d8fcb92 7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents: 20145
diff changeset
  1406
            try {
78e51d8fcb92 7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents: 20145
diff changeset
  1407
                return platformResources.getString(key);
78e51d8fcb92 7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents: 20145
diff changeset
  1408
            }
78e51d8fcb92 7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents: 20145
diff changeset
  1409
            catch (MissingResourceException e) {}
78e51d8fcb92 7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents: 20145
diff changeset
  1410
        }
78e51d8fcb92 7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents: 20145
diff changeset
  1411
78e51d8fcb92 7129133: [macosx] Accelerators are displayed as Meta instead of the Command symbol
leonidr
parents: 20145
diff changeset
  1412
        // then shared one
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1413
        if (resources != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1414
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1415
                return resources.getString(key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1416
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1417
            catch (MissingResourceException e) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1418
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1419
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1420
        return defaultValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1421
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1422
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1423
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1424
     * Get the application's or applet's EventQueue instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1425
     * Depending on the Toolkit implementation, different EventQueues
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1426
     * may be returned for different applets.  Applets should
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1427
     * therefore not assume that the EventQueue instance returned
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1428
     * by this method will be shared by other applets or the system.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1429
     *
19807
9f7860fad128 8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents: 18275
diff changeset
  1430
     * <p> If there is a security manager then its
9f7860fad128 8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents: 18275
diff changeset
  1431
     * {@link SecurityManager#checkPermission checkPermission} method
9f7860fad128 8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents: 18275
diff changeset
  1432
     * is called to check {@code AWTPermission("accessEventQueue")}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1433
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1434
     * @return    the {@code EventQueue} object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1435
     * @throws  SecurityException
19807
9f7860fad128 8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents: 18275
diff changeset
  1436
     *          if a security manager is set and it denies access to
9f7860fad128 8008981: Deprecate SecurityManager checkTopLevelWindow, checkSystemClipboardAccess, checkAwtEventQueueAccess
alanb
parents: 18275
diff changeset
  1437
     *          the {@code EventQueue}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1438
     * @see     java.awt.AWTPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1439
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1440
    public final EventQueue getSystemEventQueue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1441
        SecurityManager security = System.getSecurityManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1442
        if (security != null) {
22060
cd4f9d7dbeda 8029886: Change SecurityManager check{TopLevelWindow, SystemClipboardAccessAwtEventQueueAccess} to check AllPermission
alanb
parents: 21957
diff changeset
  1443
            security.checkPermission(AWTPermissions.CHECK_AWT_EVENTQUEUE_PERMISSION);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1444
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1445
        return getSystemEventQueueImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1446
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1447
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1448
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1449
     * Gets the application's or applet's {@code EventQueue}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1450
     * instance, without checking access.  For security reasons,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1451
     * this can only be called from a {@code Toolkit} subclass.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1452
     * @return the {@code EventQueue} object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1453
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1454
    protected abstract EventQueue getSystemEventQueueImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1455
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1456
    /* Accessor method for use by AWT package routines. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1457
    static EventQueue getEventQueue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1458
        return getDefaultToolkit().getSystemEventQueueImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1459
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1460
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1461
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1462
     * Creates a concrete, platform dependent, subclass of the abstract
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1463
     * DragGestureRecognizer class requested, and associates it with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1464
     * DragSource, Component and DragGestureListener specified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1465
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1466
     * subclasses should override this to provide their own implementation
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1467
     *
29886
545c0c3809b8 8075081: Fix missing doclint warnings in java.awt
darcy
parents: 27565
diff changeset
  1468
     * @param <T> the type of DragGestureRecognizer to create
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1469
     * @param abstractRecognizerClass The abstract class of the required recognizer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1470
     * @param ds                      The DragSource
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1471
     * @param c                       The Component target for the DragGestureRecognizer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1472
     * @param srcActions              The actions permitted for the gesture
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1473
     * @param dgl                     The DragGestureListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1474
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1475
     * @return the new object or null.  Always returns null if
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1476
     * GraphicsEnvironment.isHeadless() returns true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1477
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1478
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1479
    public <T extends DragGestureRecognizer> T
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1480
        createDragGestureRecognizer(Class<T> abstractRecognizerClass,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1481
                                    DragSource ds, Component c, int srcActions,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1482
                                    DragGestureListener dgl)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1483
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1484
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1485
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1486
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1487
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1488
     * Obtains a value for the specified desktop property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1489
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1490
     * A desktop property is a uniquely named value for a resource that
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1491
     * is Toolkit global in nature. Usually it also is an abstract
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1492
     * representation for an underlying platform dependent desktop setting.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1493
     * For more information on desktop properties supported by the AWT see
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1494
     * <a href="doc-files/DesktopProperties.html">AWT Desktop Properties</a>.
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1495
     *
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1496
     * @param  propertyName the property name
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1497
     * @return the value for the specified desktop property
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1498
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1499
    public final synchronized Object getDesktopProperty(String propertyName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1500
        // This is a workaround for headless toolkits.  It would be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1501
        // better to override this method but it is declared final.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1502
        // "this instanceof" syntax defeats polymorphism.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1503
        // --mm, 03/03/00
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1504
        if (this instanceof HeadlessToolkit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1505
            return ((HeadlessToolkit)this).getUnderlyingToolkit()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1506
                .getDesktopProperty(propertyName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1507
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1508
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1509
        if (desktopProperties.isEmpty()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1510
            initializeDesktopProperties();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1511
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1512
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1513
        Object value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1514
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1515
        // This property should never be cached
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1516
        if (propertyName.equals("awt.dynamicLayoutSupported")) {
21275
38d2199adb1a 7172770: Default Toolkit implementation return null value for property "awt.dynamicLayoutSupported"
serb
parents: 20455
diff changeset
  1517
            return getDefaultToolkit().lazilyLoadDesktopProperty(propertyName);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1518
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1519
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1520
        value = desktopProperties.get(propertyName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1521
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1522
        if (value == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1523
            value = lazilyLoadDesktopProperty(propertyName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1524
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1525
            if (value != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1526
                setDesktopProperty(propertyName, value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1527
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1528
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1529
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1530
        /* for property "awt.font.desktophints" */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1531
        if (value instanceof RenderingHints) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1532
            value = ((RenderingHints)value).clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1533
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1534
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1535
        return value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1536
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1537
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1538
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1539
     * Sets the named desktop property to the specified value and fires a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1540
     * property change event to notify any listeners that the value has changed.
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1541
     *
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1542
     * @param  name the property name
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1543
     * @param  newValue the new property value
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1544
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1545
    protected final void setDesktopProperty(String name, Object newValue) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1546
        // This is a workaround for headless toolkits.  It would be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1547
        // better to override this method but it is declared final.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1548
        // "this instanceof" syntax defeats polymorphism.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1549
        // --mm, 03/03/00
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1550
        if (this instanceof HeadlessToolkit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1551
            ((HeadlessToolkit)this).getUnderlyingToolkit()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1552
                .setDesktopProperty(name, newValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1553
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1554
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1555
        Object oldValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1556
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1557
        synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1558
            oldValue = desktopProperties.get(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1559
            desktopProperties.put(name, newValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1560
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1561
7009
cd2a85b8534b 6816582: WindowsFileChooserUI throws NullPointer when awt.useSystemAAFontSettings=false
rupashka
parents: 5506
diff changeset
  1562
        // Don't fire change event if old and new values are null.
cd2a85b8534b 6816582: WindowsFileChooserUI throws NullPointer when awt.useSystemAAFontSettings=false
rupashka
parents: 5506
diff changeset
  1563
        // It helps to avoid recursive resending of WM_THEMECHANGED
cd2a85b8534b 6816582: WindowsFileChooserUI throws NullPointer when awt.useSystemAAFontSettings=false
rupashka
parents: 5506
diff changeset
  1564
        if (oldValue != null || newValue != null) {
cd2a85b8534b 6816582: WindowsFileChooserUI throws NullPointer when awt.useSystemAAFontSettings=false
rupashka
parents: 5506
diff changeset
  1565
            desktopPropsSupport.firePropertyChange(name, oldValue, newValue);
cd2a85b8534b 6816582: WindowsFileChooserUI throws NullPointer when awt.useSystemAAFontSettings=false
rupashka
parents: 5506
diff changeset
  1566
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1567
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1568
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1569
    /**
29886
545c0c3809b8 8075081: Fix missing doclint warnings in java.awt
darcy
parents: 27565
diff changeset
  1570
     * An opportunity to lazily evaluate desktop property values.
545c0c3809b8 8075081: Fix missing doclint warnings in java.awt
darcy
parents: 27565
diff changeset
  1571
     * @return the desktop property or null
545c0c3809b8 8075081: Fix missing doclint warnings in java.awt
darcy
parents: 27565
diff changeset
  1572
     * @param name the name
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1573
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1574
    protected Object lazilyLoadDesktopProperty(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1575
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1576
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1577
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1578
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1579
     * initializeDesktopProperties
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1580
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1581
    protected void initializeDesktopProperties() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1582
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1583
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1584
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1585
     * Adds the specified property change listener for the named desktop
9764
2c32301ba9b8 7046325: Broken links in java.awt.Toolkit's javadoc
denis
parents: 9661
diff changeset
  1586
     * property. When a {@link java.beans.PropertyChangeListenerProxy} object is added,
9475
abbee6a5fcef 7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents: 9210
diff changeset
  1587
     * its property name is ignored, and the wrapped listener is added.
abbee6a5fcef 7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents: 9210
diff changeset
  1588
     * If {@code name} is {@code null} or {@code pcl} is {@code null},
abbee6a5fcef 7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents: 9210
diff changeset
  1589
     * no exception is thrown and no action is performed.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1590
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1591
     * @param   name The name of the property to listen for
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1592
     * @param   pcl The property change listener
9475
abbee6a5fcef 7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents: 9210
diff changeset
  1593
     * @see PropertyChangeSupport#addPropertyChangeListener(String,
abbee6a5fcef 7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents: 9210
diff changeset
  1594
                PropertyChangeListener)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1595
     * @since   1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1596
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1597
    public void addPropertyChangeListener(String name, PropertyChangeListener pcl) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1598
        desktopPropsSupport.addPropertyChangeListener(name, pcl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1599
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1600
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1601
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1602
     * Removes the specified property change listener for the named
9764
2c32301ba9b8 7046325: Broken links in java.awt.Toolkit's javadoc
denis
parents: 9661
diff changeset
  1603
     * desktop property. When a {@link java.beans.PropertyChangeListenerProxy} object
9475
abbee6a5fcef 7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents: 9210
diff changeset
  1604
     * is removed, its property name is ignored, and
abbee6a5fcef 7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents: 9210
diff changeset
  1605
     * the wrapped listener is removed.
abbee6a5fcef 7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents: 9210
diff changeset
  1606
     * If {@code name} is {@code null} or {@code pcl} is {@code null},
abbee6a5fcef 7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents: 9210
diff changeset
  1607
     * no exception is thrown and no action is performed.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1608
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1609
     * @param   name The name of the property to remove
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1610
     * @param   pcl The property change listener
9475
abbee6a5fcef 7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents: 9210
diff changeset
  1611
     * @see PropertyChangeSupport#removePropertyChangeListener(String,
abbee6a5fcef 7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents: 9210
diff changeset
  1612
                PropertyChangeListener)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1613
     * @since   1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1614
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1615
    public void removePropertyChangeListener(String name, PropertyChangeListener pcl) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1616
        desktopPropsSupport.removePropertyChangeListener(name, pcl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1617
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1618
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1619
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1620
     * Returns an array of all the property change listeners
9475
abbee6a5fcef 7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents: 9210
diff changeset
  1621
     * registered on this toolkit. The returned array
9764
2c32301ba9b8 7046325: Broken links in java.awt.Toolkit's javadoc
denis
parents: 9661
diff changeset
  1622
     * contains {@link java.beans.PropertyChangeListenerProxy} objects
9475
abbee6a5fcef 7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents: 9210
diff changeset
  1623
     * that associate listeners with the names of desktop properties.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1624
     *
9764
2c32301ba9b8 7046325: Broken links in java.awt.Toolkit's javadoc
denis
parents: 9661
diff changeset
  1625
     * @return all of this toolkit's {@link PropertyChangeListener}
2c32301ba9b8 7046325: Broken links in java.awt.Toolkit's javadoc
denis
parents: 9661
diff changeset
  1626
     *         objects wrapped in {@code java.beans.PropertyChangeListenerProxy} objects
9475
abbee6a5fcef 7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents: 9210
diff changeset
  1627
     *         or an empty array  if no listeners are added
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1628
     *
9475
abbee6a5fcef 7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents: 9210
diff changeset
  1629
     * @see PropertyChangeSupport#getPropertyChangeListeners()
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1630
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1631
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1632
    public PropertyChangeListener[] getPropertyChangeListeners() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1633
        return desktopPropsSupport.getPropertyChangeListeners();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1634
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1635
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1636
    /**
9475
abbee6a5fcef 7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents: 9210
diff changeset
  1637
     * Returns an array of all property change listeners
abbee6a5fcef 7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents: 9210
diff changeset
  1638
     * associated with the specified name of a desktop property.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1639
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1640
     * @param  propertyName the named property
9475
abbee6a5fcef 7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents: 9210
diff changeset
  1641
     * @return all of the {@code PropertyChangeListener} objects
abbee6a5fcef 7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents: 9210
diff changeset
  1642
     *         associated with the specified name of a desktop property
abbee6a5fcef 7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents: 9210
diff changeset
  1643
     *         or an empty array if no such listeners are added
abbee6a5fcef 7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents: 9210
diff changeset
  1644
     *
abbee6a5fcef 7020922: java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
denis
parents: 9210
diff changeset
  1645
     * @see PropertyChangeSupport#getPropertyChangeListeners(String)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1646
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1647
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1648
    public PropertyChangeListener[] getPropertyChangeListeners(String propertyName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1649
        return desktopPropsSupport.getPropertyChangeListeners(propertyName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1650
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1651
29886
545c0c3809b8 8075081: Fix missing doclint warnings in java.awt
darcy
parents: 27565
diff changeset
  1652
    /**
545c0c3809b8 8075081: Fix missing doclint warnings in java.awt
darcy
parents: 27565
diff changeset
  1653
     * The desktop properties.
545c0c3809b8 8075081: Fix missing doclint warnings in java.awt
darcy
parents: 27565
diff changeset
  1654
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1655
    protected final Map<String,Object> desktopProperties =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1656
            new HashMap<String,Object>();
29886
545c0c3809b8 8075081: Fix missing doclint warnings in java.awt
darcy
parents: 27565
diff changeset
  1657
    /**
545c0c3809b8 8075081: Fix missing doclint warnings in java.awt
darcy
parents: 27565
diff changeset
  1658
     * The desktop properties change support.
545c0c3809b8 8075081: Fix missing doclint warnings in java.awt
darcy
parents: 27565
diff changeset
  1659
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1660
    protected final PropertyChangeSupport desktopPropsSupport =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1661
            Toolkit.createPropertyChangeSupport(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1662
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1663
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1664
     * Returns whether the always-on-top mode is supported by this toolkit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1665
     * To detect whether the always-on-top mode is supported for a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1666
     * particular Window, use {@link Window#isAlwaysOnTopSupported}.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1667
     * @return {@code true}, if current toolkit supports the always-on-top mode,
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1668
     *     otherwise returns {@code false}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1669
     * @see Window#isAlwaysOnTopSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1670
     * @see Window#setAlwaysOnTop(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1671
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1672
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1673
    public boolean isAlwaysOnTopSupported() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1674
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1675
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1676
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1677
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1678
     * Returns whether the given modality type is supported by this toolkit. If
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1679
     * a dialog with unsupported modality type is created, then
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1680
     * {@code Dialog.ModalityType.MODELESS} is used instead.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1681
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1682
     * @param modalityType modality type to be checked for support by this toolkit
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1683
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1684
     * @return {@code true}, if current toolkit supports given modality
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1685
     *     type, {@code false} otherwise
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1686
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1687
     * @see java.awt.Dialog.ModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1688
     * @see java.awt.Dialog#getModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1689
     * @see java.awt.Dialog#setModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1690
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1691
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1692
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1693
    public abstract boolean isModalityTypeSupported(Dialog.ModalityType modalityType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1694
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1695
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1696
     * Returns whether the given modal exclusion type is supported by this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1697
     * toolkit. If an unsupported modal exclusion type property is set on a window,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1698
     * then {@code Dialog.ModalExclusionType.NO_EXCLUDE} is used instead.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1699
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1700
     * @param modalExclusionType modal exclusion type to be checked for support by this toolkit
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1701
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1702
     * @return {@code true}, if current toolkit supports given modal exclusion
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1703
     *     type, {@code false} otherwise
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1704
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1705
     * @see java.awt.Dialog.ModalExclusionType
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1706
     * @see java.awt.Window#getModalExclusionType
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1707
     * @see java.awt.Window#setModalExclusionType
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1708
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1709
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1710
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1711
    public abstract boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType modalExclusionType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1712
18271
228440e64512 8014718: Netbeans IDE begins to throw a lot exceptions since 7u25 b10
leonidr
parents: 15318
diff changeset
  1713
    // 8014718: logging has been removed from SunToolkit
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1714
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1715
    private static final int LONG_BITS = 64;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1716
    private int[] calls = new int[LONG_BITS];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1717
    private static volatile long enabledOnToolkitMask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1718
    private AWTEventListener eventListener = null;
11270
d7b0b63bd082 7117334: Warnings cleanup day: reduce number of javac warnings in the java.awt package
bagiras
parents: 10068
diff changeset
  1719
    private WeakHashMap<AWTEventListener, SelectiveAWTEventListener> listener2SelectiveListener = new WeakHashMap<>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1720
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1721
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1722
     * Extracts a "pure" AWTEventListener from a AWTEventListenerProxy,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1723
     * if the listener is proxied.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1724
     */
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 32491
diff changeset
  1725
    private static AWTEventListener deProxyAWTEventListener(AWTEventListener l)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1726
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1727
        AWTEventListener localL = l;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1728
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1729
        if (localL == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1730
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1731
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1732
        // if user passed in a AWTEventListenerProxy object, extract
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1733
        // the listener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1734
        if (l instanceof AWTEventListenerProxy) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1735
            localL = ((AWTEventListenerProxy)l).getListener();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1736
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1737
        return localL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1738
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1739
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1740
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1741
     * Adds an AWTEventListener to receive all AWTEvents dispatched
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1742
     * system-wide that conform to the given {@code eventMask}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1743
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1744
     * First, if there is a security manager, its {@code checkPermission}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1745
     * method is called with an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1746
     * {@code AWTPermission("listenToAllAWTEvents")} permission.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1747
     * This may result in a SecurityException.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1748
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1749
     * {@code eventMask} is a bitmask of event types to receive.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1750
     * It is constructed by bitwise OR-ing together the event masks
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1751
     * defined in {@code AWTEvent}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1752
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1753
     * Note:  event listener use is not recommended for normal
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1754
     * application use, but are intended solely to support special
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1755
     * purpose facilities including support for accessibility,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1756
     * event record/playback, and diagnostic tracing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1757
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1758
     * If listener is null, no exception is thrown and no action is performed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1759
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1760
     * @param    listener   the event listener.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1761
     * @param    eventMask  the bitmask of event types to receive
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1762
     * @throws SecurityException
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1763
     *        if a security manager exists and its
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1764
     *        {@code checkPermission} method doesn't allow the operation.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1765
     * @see      #removeAWTEventListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1766
     * @see      #getAWTEventListeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1767
     * @see      SecurityManager#checkPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1768
     * @see      java.awt.AWTEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1769
     * @see      java.awt.AWTPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1770
     * @see      java.awt.event.AWTEventListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1771
     * @see      java.awt.event.AWTEventListenerProxy
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1772
     * @since    1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1773
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1774
    public void addAWTEventListener(AWTEventListener listener, long eventMask) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1775
        AWTEventListener localL = deProxyAWTEventListener(listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1776
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1777
        if (localL == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1778
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1779
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1780
        SecurityManager security = System.getSecurityManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1781
        if (security != null) {
22060
cd4f9d7dbeda 8029886: Change SecurityManager check{TopLevelWindow, SystemClipboardAccessAwtEventQueueAccess} to check AllPermission
alanb
parents: 21957
diff changeset
  1782
          security.checkPermission(AWTPermissions.ALL_AWT_EVENTS_PERMISSION);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1783
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1784
        synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1785
            SelectiveAWTEventListener selectiveListener =
11270
d7b0b63bd082 7117334: Warnings cleanup day: reduce number of javac warnings in the java.awt package
bagiras
parents: 10068
diff changeset
  1786
                listener2SelectiveListener.get(localL);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1787
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1788
            if (selectiveListener == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1789
                // Create a new selectiveListener.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1790
                selectiveListener = new SelectiveAWTEventListener(localL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1791
                                                                 eventMask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1792
                listener2SelectiveListener.put(localL, selectiveListener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1793
                eventListener = ToolkitEventMulticaster.add(eventListener,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1794
                                                            selectiveListener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1795
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1796
            // OR the eventMask into the selectiveListener's event mask.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1797
            selectiveListener.orEventMasks(eventMask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1798
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1799
            enabledOnToolkitMask |= eventMask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1800
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1801
            long mask = eventMask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1802
            for (int i=0; i<LONG_BITS; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1803
                // If no bits are set, break out of loop.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1804
                if (mask == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1805
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1806
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1807
                if ((mask & 1L) != 0) {  // Always test bit 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1808
                    calls[i]++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1809
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1810
                mask >>>= 1;  // Right shift, fill with zeros on left.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1811
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1812
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1813
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1814
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1815
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1816
     * Removes an AWTEventListener from receiving dispatched AWTEvents.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1817
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1818
     * First, if there is a security manager, its {@code checkPermission}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1819
     * method is called with an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1820
     * {@code AWTPermission("listenToAllAWTEvents")} permission.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1821
     * This may result in a SecurityException.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1822
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1823
     * Note:  event listener use is not recommended for normal
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1824
     * application use, but are intended solely to support special
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1825
     * purpose facilities including support for accessibility,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1826
     * event record/playback, and diagnostic tracing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1827
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1828
     * If listener is null, no exception is thrown and no action is performed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1829
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1830
     * @param    listener   the event listener.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1831
     * @throws SecurityException
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1832
     *        if a security manager exists and its
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1833
     *        {@code checkPermission} method doesn't allow the operation.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1834
     * @see      #addAWTEventListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1835
     * @see      #getAWTEventListeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1836
     * @see      SecurityManager#checkPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1837
     * @see      java.awt.AWTEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1838
     * @see      java.awt.AWTPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1839
     * @see      java.awt.event.AWTEventListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1840
     * @see      java.awt.event.AWTEventListenerProxy
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1841
     * @since    1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1842
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1843
    public void removeAWTEventListener(AWTEventListener listener) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1844
        AWTEventListener localL = deProxyAWTEventListener(listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1845
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1846
        if (listener == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1847
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1848
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1849
        SecurityManager security = System.getSecurityManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1850
        if (security != null) {
22060
cd4f9d7dbeda 8029886: Change SecurityManager check{TopLevelWindow, SystemClipboardAccessAwtEventQueueAccess} to check AllPermission
alanb
parents: 21957
diff changeset
  1851
            security.checkPermission(AWTPermissions.ALL_AWT_EVENTS_PERMISSION);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1852
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1853
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1854
        synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1855
            SelectiveAWTEventListener selectiveListener =
11270
d7b0b63bd082 7117334: Warnings cleanup day: reduce number of javac warnings in the java.awt package
bagiras
parents: 10068
diff changeset
  1856
                listener2SelectiveListener.get(localL);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1857
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1858
            if (selectiveListener != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1859
                listener2SelectiveListener.remove(localL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1860
                int[] listenerCalls = selectiveListener.getCalls();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1861
                for (int i=0; i<LONG_BITS; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1862
                    calls[i] -= listenerCalls[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1863
                    assert calls[i] >= 0: "Negative Listeners count";
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1864
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1865
                    if (calls[i] == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1866
                        enabledOnToolkitMask &= ~(1L<<i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1867
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1868
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1869
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1870
            eventListener = ToolkitEventMulticaster.remove(eventListener,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1871
            (selectiveListener == null) ? localL : selectiveListener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1872
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1873
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1874
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1875
    static boolean enabledOnToolkit(long eventMask) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1876
        return (enabledOnToolkitMask & eventMask) != 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1877
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1878
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1879
    synchronized int countAWTEventListeners(long eventMask) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1880
        int ci = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1881
        for (; eventMask != 0; eventMask >>>= 1, ci++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1882
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1883
        ci--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1884
        return calls[ci];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1885
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1886
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1887
     * Returns an array of all the {@code AWTEventListener}s
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1888
     * registered on this toolkit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1889
     * If there is a security manager, its {@code checkPermission}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1890
     * method is called with an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1891
     * {@code AWTPermission("listenToAllAWTEvents")} permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1892
     * This may result in a SecurityException.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1893
     * Listeners can be returned
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1894
     * within {@code AWTEventListenerProxy} objects, which also contain
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1895
     * the event mask for the given listener.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1896
     * Note that listener objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1897
     * added multiple times appear only once in the returned array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1898
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1899
     * @return all of the {@code AWTEventListener}s or an empty
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1900
     *         array if no listeners are currently registered
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1901
     * @throws SecurityException
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1902
     *        if a security manager exists and its
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1903
     *        {@code checkPermission} method doesn't allow the operation.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1904
     * @see      #addAWTEventListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1905
     * @see      #removeAWTEventListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1906
     * @see      SecurityManager#checkPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1907
     * @see      java.awt.AWTEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1908
     * @see      java.awt.AWTPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1909
     * @see      java.awt.event.AWTEventListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1910
     * @see      java.awt.event.AWTEventListenerProxy
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1911
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1912
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1913
    public AWTEventListener[] getAWTEventListeners() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1914
        SecurityManager security = System.getSecurityManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1915
        if (security != null) {
22060
cd4f9d7dbeda 8029886: Change SecurityManager check{TopLevelWindow, SystemClipboardAccessAwtEventQueueAccess} to check AllPermission
alanb
parents: 21957
diff changeset
  1916
            security.checkPermission(AWTPermissions.ALL_AWT_EVENTS_PERMISSION);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1917
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1918
        synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1919
            EventListener[] la = ToolkitEventMulticaster.getListeners(eventListener,AWTEventListener.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1920
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1921
            AWTEventListener[] ret = new AWTEventListener[la.length];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1922
            for (int i = 0; i < la.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1923
                SelectiveAWTEventListener sael = (SelectiveAWTEventListener)la[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1924
                AWTEventListener tempL = sael.getListener();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1925
                //assert tempL is not an AWTEventListenerProxy - we should
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1926
                // have weeded them all out
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1927
                // don't want to wrap a proxy inside a proxy
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1928
                ret[i] = new AWTEventListenerProxy(sael.getEventMask(), tempL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1929
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1930
            return ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1931
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1932
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1933
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1934
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1935
     * Returns an array of all the {@code AWTEventListener}s
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1936
     * registered on this toolkit which listen to all of the event
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1937
     * types specified in the {@code eventMask} argument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1938
     * If there is a security manager, its {@code checkPermission}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1939
     * method is called with an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1940
     * {@code AWTPermission("listenToAllAWTEvents")} permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1941
     * This may result in a SecurityException.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1942
     * Listeners can be returned
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1943
     * within {@code AWTEventListenerProxy} objects, which also contain
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1944
     * the event mask for the given listener.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1945
     * Note that listener objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1946
     * added multiple times appear only once in the returned array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1947
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1948
     * @param  eventMask the bitmask of event types to listen for
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1949
     * @return all of the {@code AWTEventListener}s registered
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1950
     *         on this toolkit for the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1951
     *         event types, or an empty array if no such listeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1952
     *         are currently registered
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1953
     * @throws SecurityException
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1954
     *        if a security manager exists and its
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1955
     *        {@code checkPermission} method doesn't allow the operation.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1956
     * @see      #addAWTEventListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1957
     * @see      #removeAWTEventListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1958
     * @see      SecurityManager#checkPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1959
     * @see      java.awt.AWTEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1960
     * @see      java.awt.AWTPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1961
     * @see      java.awt.event.AWTEventListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1962
     * @see      java.awt.event.AWTEventListenerProxy
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1963
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1964
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1965
    public AWTEventListener[] getAWTEventListeners(long eventMask) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1966
        SecurityManager security = System.getSecurityManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1967
        if (security != null) {
22060
cd4f9d7dbeda 8029886: Change SecurityManager check{TopLevelWindow, SystemClipboardAccessAwtEventQueueAccess} to check AllPermission
alanb
parents: 21957
diff changeset
  1968
            security.checkPermission(AWTPermissions.ALL_AWT_EVENTS_PERMISSION);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1969
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1970
        synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1971
            EventListener[] la = ToolkitEventMulticaster.getListeners(eventListener,AWTEventListener.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1972
11270
d7b0b63bd082 7117334: Warnings cleanup day: reduce number of javac warnings in the java.awt package
bagiras
parents: 10068
diff changeset
  1973
            java.util.List<AWTEventListenerProxy> list = new ArrayList<>(la.length);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1974
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1975
            for (int i = 0; i < la.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1976
                SelectiveAWTEventListener sael = (SelectiveAWTEventListener)la[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1977
                if ((sael.getEventMask() & eventMask) == eventMask) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1978
                    //AWTEventListener tempL = sael.getListener();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1979
                    list.add(new AWTEventListenerProxy(sael.getEventMask(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1980
                                                       sael.getListener()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1981
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1982
            }
11270
d7b0b63bd082 7117334: Warnings cleanup day: reduce number of javac warnings in the java.awt package
bagiras
parents: 10068
diff changeset
  1983
            return list.toArray(new AWTEventListener[0]);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1984
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1985
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1986
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1987
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1988
     * This method notifies any AWTEventListeners that an event
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1989
     * is about to be dispatched.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1990
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1991
     * @param theEvent the event which will be dispatched.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1992
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1993
    void notifyAWTEventListeners(AWTEvent theEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1994
        // This is a workaround for headless toolkits.  It would be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1995
        // better to override this method but it is declared package private.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1996
        // "this instanceof" syntax defeats polymorphism.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1997
        // --mm, 03/03/00
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1998
        if (this instanceof HeadlessToolkit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1999
            ((HeadlessToolkit)this).getUnderlyingToolkit()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2000
                .notifyAWTEventListeners(theEvent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2001
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2002
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2003
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2004
        AWTEventListener eventListener = this.eventListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2005
        if (eventListener != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2006
            eventListener.eventDispatched(theEvent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2007
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2008
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2009
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 32491
diff changeset
  2010
    private static class ToolkitEventMulticaster extends AWTEventMulticaster
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2011
        implements AWTEventListener {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2012
        // Implementation cloned from AWTEventMulticaster.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2013
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2014
        ToolkitEventMulticaster(AWTEventListener a, AWTEventListener b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2015
            super(a, b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2016
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2017
22282
cf7ce8b79a25 8031550: Fix overloads lint warnings in client code
darcy
parents: 22060
diff changeset
  2018
        @SuppressWarnings("overloads")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2019
        static AWTEventListener add(AWTEventListener a,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2020
                                    AWTEventListener b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2021
            if (a == null)  return b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2022
            if (b == null)  return a;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2023
            return new ToolkitEventMulticaster(a, b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2024
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2025
22282
cf7ce8b79a25 8031550: Fix overloads lint warnings in client code
darcy
parents: 22060
diff changeset
  2026
        @SuppressWarnings("overloads")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2027
        static AWTEventListener remove(AWTEventListener l,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2028
                                       AWTEventListener oldl) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2029
            return (AWTEventListener) removeInternal(l, oldl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2030
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2031
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2032
        // #4178589: must overload remove(EventListener) to call our add()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2033
        // instead of the static addInternal() so we allocate a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2034
        // ToolkitEventMulticaster instead of an AWTEventMulticaster.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2035
        // Note: this method is called by AWTEventListener.removeInternal(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2036
        // so its method signature must match AWTEventListener.remove().
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2037
        protected EventListener remove(EventListener oldl) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2038
            if (oldl == a)  return b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2039
            if (oldl == b)  return a;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2040
            AWTEventListener a2 = (AWTEventListener)removeInternal(a, oldl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2041
            AWTEventListener b2 = (AWTEventListener)removeInternal(b, oldl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2042
            if (a2 == a && b2 == b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2043
                return this;    // it's not here
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2044
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2045
            return add(a2, b2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2046
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2047
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2048
        public void eventDispatched(AWTEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2049
            ((AWTEventListener)a).eventDispatched(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2050
            ((AWTEventListener)b).eventDispatched(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2051
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2052
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2053
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2054
    private class SelectiveAWTEventListener implements AWTEventListener {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2055
        AWTEventListener listener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2056
        private long eventMask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2057
        // This array contains the number of times to call the eventlistener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2058
        // for each event type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2059
        int[] calls = new int[Toolkit.LONG_BITS];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2060
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2061
        public AWTEventListener getListener() {return listener;}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2062
        public long getEventMask() {return eventMask;}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2063
        public int[] getCalls() {return calls;}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2064
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2065
        public void orEventMasks(long mask) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2066
            eventMask |= mask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2067
            // For each event bit set in mask, increment its call count.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2068
            for (int i=0; i<Toolkit.LONG_BITS; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2069
                // If no bits are set, break out of loop.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2070
                if (mask == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2071
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2072
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2073
                if ((mask & 1L) != 0) {  // Always test bit 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2074
                    calls[i]++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2075
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2076
                mask >>>= 1;  // Right shift, fill with zeros on left.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2077
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2078
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2079
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2080
        SelectiveAWTEventListener(AWTEventListener l, long mask) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2081
            listener = l;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2082
            eventMask = mask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2083
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2084
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2085
        public void eventDispatched(AWTEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2086
            long eventBit = 0; // Used to save the bit of the event type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2087
            if (((eventBit = eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2088
                 event.id >= ComponentEvent.COMPONENT_FIRST &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2089
                 event.id <= ComponentEvent.COMPONENT_LAST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2090
             || ((eventBit = eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2091
                 event.id >= ContainerEvent.CONTAINER_FIRST &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2092
                 event.id <= ContainerEvent.CONTAINER_LAST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2093
             || ((eventBit = eventMask & AWTEvent.FOCUS_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2094
                 event.id >= FocusEvent.FOCUS_FIRST &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2095
                 event.id <= FocusEvent.FOCUS_LAST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2096
             || ((eventBit = eventMask & AWTEvent.KEY_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2097
                 event.id >= KeyEvent.KEY_FIRST &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2098
                 event.id <= KeyEvent.KEY_LAST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2099
             || ((eventBit = eventMask & AWTEvent.MOUSE_WHEEL_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2100
                 event.id == MouseEvent.MOUSE_WHEEL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2101
             || ((eventBit = eventMask & AWTEvent.MOUSE_MOTION_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2102
                 (event.id == MouseEvent.MOUSE_MOVED ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2103
                  event.id == MouseEvent.MOUSE_DRAGGED))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2104
             || ((eventBit = eventMask & AWTEvent.MOUSE_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2105
                 event.id != MouseEvent.MOUSE_MOVED &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2106
                 event.id != MouseEvent.MOUSE_DRAGGED &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2107
                 event.id != MouseEvent.MOUSE_WHEEL &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2108
                 event.id >= MouseEvent.MOUSE_FIRST &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2109
                 event.id <= MouseEvent.MOUSE_LAST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2110
             || ((eventBit = eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2111
                 (event.id >= WindowEvent.WINDOW_FIRST &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2112
                 event.id <= WindowEvent.WINDOW_LAST))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2113
             || ((eventBit = eventMask & AWTEvent.ACTION_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2114
                 event.id >= ActionEvent.ACTION_FIRST &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2115
                 event.id <= ActionEvent.ACTION_LAST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2116
             || ((eventBit = eventMask & AWTEvent.ADJUSTMENT_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2117
                 event.id >= AdjustmentEvent.ADJUSTMENT_FIRST &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2118
                 event.id <= AdjustmentEvent.ADJUSTMENT_LAST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2119
             || ((eventBit = eventMask & AWTEvent.ITEM_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2120
                 event.id >= ItemEvent.ITEM_FIRST &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2121
                 event.id <= ItemEvent.ITEM_LAST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2122
             || ((eventBit = eventMask & AWTEvent.TEXT_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2123
                 event.id >= TextEvent.TEXT_FIRST &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2124
                 event.id <= TextEvent.TEXT_LAST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2125
             || ((eventBit = eventMask & AWTEvent.INPUT_METHOD_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2126
                 event.id >= InputMethodEvent.INPUT_METHOD_FIRST &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2127
                 event.id <= InputMethodEvent.INPUT_METHOD_LAST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2128
             || ((eventBit = eventMask & AWTEvent.PAINT_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2129
                 event.id >= PaintEvent.PAINT_FIRST &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2130
                 event.id <= PaintEvent.PAINT_LAST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2131
             || ((eventBit = eventMask & AWTEvent.INVOCATION_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2132
                 event.id >= InvocationEvent.INVOCATION_FIRST &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2133
                 event.id <= InvocationEvent.INVOCATION_LAST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2134
             || ((eventBit = eventMask & AWTEvent.HIERARCHY_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2135
                 event.id == HierarchyEvent.HIERARCHY_CHANGED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2136
             || ((eventBit = eventMask & AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2137
                 (event.id == HierarchyEvent.ANCESTOR_MOVED ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2138
                  event.id == HierarchyEvent.ANCESTOR_RESIZED))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2139
             || ((eventBit = eventMask & AWTEvent.WINDOW_STATE_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2140
                 event.id == WindowEvent.WINDOW_STATE_CHANGED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2141
             || ((eventBit = eventMask & AWTEvent.WINDOW_FOCUS_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2142
                 (event.id == WindowEvent.WINDOW_GAINED_FOCUS ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2143
                  event.id == WindowEvent.WINDOW_LOST_FOCUS))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2144
                || ((eventBit = eventMask & sun.awt.SunToolkit.GRAB_EVENT_MASK) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2145
                    (event instanceof sun.awt.UngrabEvent))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2146
                // Get the index of the call count for this event type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2147
                // Instead of using Math.log(...) we will calculate it with
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2148
                // bit shifts. That's what previous implementation looked like:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2149
                //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2150
                // int ci = (int) (Math.log(eventBit)/Math.log(2));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2151
                int ci = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2152
                for (long eMask = eventBit; eMask != 0; eMask >>>= 1, ci++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2153
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2154
                ci--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2155
                // Call the listener as many times as it was added for this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2156
                // event type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2157
                for (int i=0; i<calls[ci]; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2158
                    listener.eventDispatched(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2159
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2160
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2161
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2162
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2163
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2164
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2165
     * Returns a map of visual attributes for the abstract level description
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2166
     * of the given input method highlight, or null if no mapping is found.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2167
     * The style field of the input method highlight is ignored. The map
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2168
     * returned is unmodifiable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2169
     * @param highlight input method highlight
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  2170
     * @return style attribute map, or {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2171
     * @exception HeadlessException if
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  2172
     *     {@code GraphicsEnvironment.isHeadless} returns true
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2173
     * @see       java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2174
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2175
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2176
    public abstract Map<java.awt.font.TextAttribute,?>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2177
        mapInputMethodHighlight(InputMethodHighlight highlight)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2178
        throws HeadlessException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2179
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2180
    private static PropertyChangeSupport createPropertyChangeSupport(Toolkit toolkit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2181
        if (toolkit instanceof SunToolkit || toolkit instanceof HeadlessToolkit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2182
            return new DesktopPropertyChangeSupport(toolkit);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2183
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2184
            return new PropertyChangeSupport(toolkit);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2185
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2186
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2187
11270
d7b0b63bd082 7117334: Warnings cleanup day: reduce number of javac warnings in the java.awt package
bagiras
parents: 10068
diff changeset
  2188
    @SuppressWarnings("serial")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2189
    private static class DesktopPropertyChangeSupport extends PropertyChangeSupport {
11270
d7b0b63bd082 7117334: Warnings cleanup day: reduce number of javac warnings in the java.awt package
bagiras
parents: 10068
diff changeset
  2190
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2191
        private static final StringBuilder PROP_CHANGE_SUPPORT_KEY =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2192
                new StringBuilder("desktop property change support key");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2193
        private final Object source;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2194
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2195
        public DesktopPropertyChangeSupport(Object sourceBean) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2196
            super(sourceBean);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2197
            source = sourceBean;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2198
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2199
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2200
        @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2201
        public synchronized void addPropertyChangeListener(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2202
                String propertyName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2203
                PropertyChangeListener listener)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2204
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2205
            PropertyChangeSupport pcs = (PropertyChangeSupport)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2206
                    AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2207
            if (null == pcs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2208
                pcs = new PropertyChangeSupport(source);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2209
                AppContext.getAppContext().put(PROP_CHANGE_SUPPORT_KEY, pcs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2210
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2211
            pcs.addPropertyChangeListener(propertyName, listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2212
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2213
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2214
        @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2215
        public synchronized void removePropertyChangeListener(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2216
                String propertyName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2217
                PropertyChangeListener listener)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2218
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2219
            PropertyChangeSupport pcs = (PropertyChangeSupport)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2220
                    AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2221
            if (null != pcs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2222
                pcs.removePropertyChangeListener(propertyName, listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2223
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2224
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2225
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2226
        @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2227
        public synchronized PropertyChangeListener[] getPropertyChangeListeners()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2228
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2229
            PropertyChangeSupport pcs = (PropertyChangeSupport)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2230
                    AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2231
            if (null != pcs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2232
                return pcs.getPropertyChangeListeners();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2233
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2234
                return new PropertyChangeListener[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2235
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2236
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2237
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2238
        @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2239
        public synchronized PropertyChangeListener[] getPropertyChangeListeners(String propertyName)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2240
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2241
            PropertyChangeSupport pcs = (PropertyChangeSupport)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2242
                    AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2243
            if (null != pcs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2244
                return pcs.getPropertyChangeListeners(propertyName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2245
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2246
                return new PropertyChangeListener[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2247
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2248
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2249
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2250
        @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2251
        public synchronized void addPropertyChangeListener(PropertyChangeListener listener) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2252
            PropertyChangeSupport pcs = (PropertyChangeSupport)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2253
                    AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2254
            if (null == pcs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2255
                pcs = new PropertyChangeSupport(source);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2256
                AppContext.getAppContext().put(PROP_CHANGE_SUPPORT_KEY, pcs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2257
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2258
            pcs.addPropertyChangeListener(listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2259
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2260
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2261
        @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2262
        public synchronized void removePropertyChangeListener(PropertyChangeListener listener) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2263
            PropertyChangeSupport pcs = (PropertyChangeSupport)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2264
                    AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2265
            if (null != pcs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2266
                pcs.removePropertyChangeListener(listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2267
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2268
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2269
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2270
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2271
         * we do expect that all other fireXXX() methods of java.beans.PropertyChangeSupport
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2272
         * use this method.  If this will be changed we will need to change this class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2273
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2274
        @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2275
        public void firePropertyChange(final PropertyChangeEvent evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2276
            Object oldValue = evt.getOldValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2277
            Object newValue = evt.getNewValue();
25544
dca3eee75c1a 8039097: Some tests fail with NPE since 7u60 b12
pchelko
parents: 25532
diff changeset
  2278
            String propertyName = evt.getPropertyName();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2279
            if (oldValue != null && newValue != null && oldValue.equals(newValue)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2280
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2281
            }
25544
dca3eee75c1a 8039097: Some tests fail with NPE since 7u60 b12
pchelko
parents: 25532
diff changeset
  2282
            Runnable updater = new Runnable() {
dca3eee75c1a 8039097: Some tests fail with NPE since 7u60 b12
pchelko
parents: 25532
diff changeset
  2283
                public void run() {
dca3eee75c1a 8039097: Some tests fail with NPE since 7u60 b12
pchelko
parents: 25532
diff changeset
  2284
                    PropertyChangeSupport pcs = (PropertyChangeSupport)
dca3eee75c1a 8039097: Some tests fail with NPE since 7u60 b12
pchelko
parents: 25532
diff changeset
  2285
                            AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY);
dca3eee75c1a 8039097: Some tests fail with NPE since 7u60 b12
pchelko
parents: 25532
diff changeset
  2286
                    if (null != pcs) {
dca3eee75c1a 8039097: Some tests fail with NPE since 7u60 b12
pchelko
parents: 25532
diff changeset
  2287
                        pcs.firePropertyChange(evt);
dca3eee75c1a 8039097: Some tests fail with NPE since 7u60 b12
pchelko
parents: 25532
diff changeset
  2288
                    }
dca3eee75c1a 8039097: Some tests fail with NPE since 7u60 b12
pchelko
parents: 25532
diff changeset
  2289
                }
dca3eee75c1a 8039097: Some tests fail with NPE since 7u60 b12
pchelko
parents: 25532
diff changeset
  2290
            };
dca3eee75c1a 8039097: Some tests fail with NPE since 7u60 b12
pchelko
parents: 25532
diff changeset
  2291
            final AppContext currentAppContext = AppContext.getAppContext();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2292
            for (AppContext appContext : AppContext.getAppContexts()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2293
                if (null == appContext || appContext.isDisposed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2294
                    continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2295
                }
25544
dca3eee75c1a 8039097: Some tests fail with NPE since 7u60 b12
pchelko
parents: 25532
diff changeset
  2296
                if (currentAppContext == appContext) {
dca3eee75c1a 8039097: Some tests fail with NPE since 7u60 b12
pchelko
parents: 25532
diff changeset
  2297
                    updater.run();
dca3eee75c1a 8039097: Some tests fail with NPE since 7u60 b12
pchelko
parents: 25532
diff changeset
  2298
                } else {
dca3eee75c1a 8039097: Some tests fail with NPE since 7u60 b12
pchelko
parents: 25532
diff changeset
  2299
                    final PeerEvent e = new PeerEvent(source, updater, PeerEvent.ULTIMATE_PRIORITY_EVENT);
dca3eee75c1a 8039097: Some tests fail with NPE since 7u60 b12
pchelko
parents: 25532
diff changeset
  2300
                    SunToolkit.postEvent(appContext, e);
dca3eee75c1a 8039097: Some tests fail with NPE since 7u60 b12
pchelko
parents: 25532
diff changeset
  2301
                }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2302
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2303
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2304
    }
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2305
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2306
    /**
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2307
    * Reports whether events from extra mouse buttons are allowed to be processed and posted into
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2308
    * {@code EventQueue}.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2309
    * <br>
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2310
    * To change the returned value it is necessary to set the {@code sun.awt.enableExtraMouseButtons}
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2311
    * property before the {@code Toolkit} class initialization. This setting could be done on the application
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2312
    * startup by the following command:
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2313
    * <pre>
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2314
    * java -Dsun.awt.enableExtraMouseButtons=false Application
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2315
    * </pre>
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2316
    * Alternatively, the property could be set in the application by using the following code:
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2317
    * <pre>
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2318
    * System.setProperty("sun.awt.enableExtraMouseButtons", "true");
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2319
    * </pre>
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2320
    * before the {@code Toolkit} class initialization.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2321
    * If not set by the time of the {@code Toolkit} class initialization, this property will be
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2322
    * initialized with {@code true}.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2323
    * Changing this value after the {@code Toolkit} class initialization will have no effect.
23717
6457189cd574 8039259: Tidy warnings cleanup for java.awt
yan
parents: 23317
diff changeset
  2324
    *
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2325
    * @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2326
    * @return {@code true} if events from extra mouse buttons are allowed to be processed and posted;
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2327
    *         {@code false} otherwise
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2328
    * @see System#getProperty(String propertyName)
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2329
    * @see System#setProperty(String propertyName, String value)
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2330
    * @see java.awt.EventQueue
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2331
    * @since 1.7
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2332
     */
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2333
    public boolean areExtraMouseButtonsEnabled() throws HeadlessException {
9656
b9011986e4c8 7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents: 9475
diff changeset
  2334
        GraphicsEnvironment.checkHeadless();
b9011986e4c8 7040577: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
dav
parents: 9475
diff changeset
  2335
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2336
        return Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled();
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 2
diff changeset
  2337
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2338
}