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