jdk/src/java.desktop/share/classes/java/awt/Cursor.java
author serb
Mon, 16 Feb 2015 20:01:17 +0300
changeset 29255 0989118f6e69
parent 25859 3317bb8137f4
child 31443 272f4e5cbb14
permissions -rw-r--r--
8039269: images/cursors should not be in ${java.home}/lib Reviewed-by: mchung, alanb, erikj
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
29255
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
     2
 * Copyright (c) 1996, 2015, 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: 3938
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: 3938
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: 3938
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package java.awt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.beans.ConstructorProperties;
29255
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
    28
import java.io.InputStream;
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
    29
import java.net.URL;
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
    30
import java.security.AccessController;
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
    31
import java.security.PrivilegedExceptionAction;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.util.Hashtable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.util.Properties;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.util.StringTokenizer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
29255
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
    36
import sun.awt.AWTAccessor;
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3711
diff changeset
    37
import sun.util.logging.PlatformLogger;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * A class to encapsulate the bitmap representation of the mouse cursor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * @see Component#setCursor
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * @author      Amy Fowler
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
public class Cursor implements java.io.Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
     * The default cursor type (gets set if no cursor is defined).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    public static final int     DEFAULT_CURSOR                  = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * The crosshair cursor type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    public static final int     CROSSHAIR_CURSOR                = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * The text cursor type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    public static final int     TEXT_CURSOR                     = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * The wait cursor type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    public static final int     WAIT_CURSOR                     = 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * The south-west-resize cursor type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    public static final int     SW_RESIZE_CURSOR                = 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * The south-east-resize cursor type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    public static final int     SE_RESIZE_CURSOR                = 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * The north-west-resize cursor type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    public static final int     NW_RESIZE_CURSOR                = 6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * The north-east-resize cursor type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    public static final int     NE_RESIZE_CURSOR                = 7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * The north-resize cursor type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    public static final int     N_RESIZE_CURSOR                 = 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * The south-resize cursor type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    public static final int     S_RESIZE_CURSOR                 = 9;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * The west-resize cursor type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    public static final int     W_RESIZE_CURSOR                 = 10;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * The east-resize cursor type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    public static final int     E_RESIZE_CURSOR                 = 11;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * The hand cursor type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    public static final int     HAND_CURSOR                     = 12;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * The move cursor type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    public static final int     MOVE_CURSOR                     = 13;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
3445
39d00a6cac5e 6656586: Cursor.predefined is protected static mutable (findbugs)
art
parents: 2
diff changeset
   117
    /**
3711
675253c23780 6877122: Many javadoc warnings from java.awt.Window, other awt classes
darcy
parents: 3445
diff changeset
   118
      * @deprecated As of JDK version 1.7, the {@link #getPredefinedCursor(int)}
3445
39d00a6cac5e 6656586: Cursor.predefined is protected static mutable (findbugs)
art
parents: 2
diff changeset
   119
      * method should be used instead.
39d00a6cac5e 6656586: Cursor.predefined is protected static mutable (findbugs)
art
parents: 2
diff changeset
   120
      */
39d00a6cac5e 6656586: Cursor.predefined is protected static mutable (findbugs)
art
parents: 2
diff changeset
   121
    @Deprecated
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    protected static Cursor predefined[] = new Cursor[14];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
3445
39d00a6cac5e 6656586: Cursor.predefined is protected static mutable (findbugs)
art
parents: 2
diff changeset
   124
    /**
39d00a6cac5e 6656586: Cursor.predefined is protected static mutable (findbugs)
art
parents: 2
diff changeset
   125
     * This field is a private replacement for 'predefined' array.
39d00a6cac5e 6656586: Cursor.predefined is protected static mutable (findbugs)
art
parents: 2
diff changeset
   126
     */
39d00a6cac5e 6656586: Cursor.predefined is protected static mutable (findbugs)
art
parents: 2
diff changeset
   127
    private final static Cursor[] predefinedPrivate = new Cursor[14];
39d00a6cac5e 6656586: Cursor.predefined is protected static mutable (findbugs)
art
parents: 2
diff changeset
   128
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    /* Localization names and default values */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    static final String[][] cursorProperties = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        { "AWT.DefaultCursor", "Default Cursor" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        { "AWT.CrosshairCursor", "Crosshair Cursor" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        { "AWT.TextCursor", "Text Cursor" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        { "AWT.WaitCursor", "Wait Cursor" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        { "AWT.SWResizeCursor", "Southwest Resize Cursor" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        { "AWT.SEResizeCursor", "Southeast Resize Cursor" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        { "AWT.NWResizeCursor", "Northwest Resize Cursor" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        { "AWT.NEResizeCursor", "Northeast Resize Cursor" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        { "AWT.NResizeCursor", "North Resize Cursor" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        { "AWT.SResizeCursor", "South Resize Cursor" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        { "AWT.WResizeCursor", "West Resize Cursor" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        { "AWT.EResizeCursor", "East Resize Cursor" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        { "AWT.HandCursor", "Hand Cursor" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        { "AWT.MoveCursor", "Move Cursor" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * The chosen cursor type initially set to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * the <code>DEFAULT_CURSOR</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * @see #getType()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    int type = DEFAULT_CURSOR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * The type associated with all custom cursors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    public static final int     CUSTOM_CURSOR                   = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    /*
29255
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
   162
     * hashtable, resource prefix, filename, and properties for custom cursors
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
   163
     * support
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     */
15994
5c8a3d840366 8007295: Reduce number of warnings in awt classes
mcherkas
parents: 13604
diff changeset
   165
    private static final Hashtable<String,Cursor> systemCustomCursors = new Hashtable<>(1);
29255
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
   166
    private static final String RESOURCE_PREFIX = "/sun/awt/resources/cursors/";
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
   167
    private static final String PROPERTIES_FILE = RESOURCE_PREFIX + "cursors.properties";
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    private static       Properties systemCustomCursorProperties = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
29255
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
   171
    private static final String CURSOR_DOT_PREFIX = "Cursor.";
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
   172
    private static final String DOT_FILE_SUFFIX = ".File";
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
   173
    private static final String DOT_HOTSPOT_SUFFIX = ".HotSpot";
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
   174
    private static final String DOT_NAME_SUFFIX = ".Name";
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * JDK 1.1 serialVersionUID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    private static final long serialVersionUID = 8028237497568985504L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3711
diff changeset
   181
    private static final PlatformLogger log = PlatformLogger.getLogger("java.awt.Cursor");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        /* ensure that the necessary native libraries are loaded */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        Toolkit.loadLibraries();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        if (!GraphicsEnvironment.isHeadless()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        }
13604
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 5506
diff changeset
   189
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 5506
diff changeset
   190
        AWTAccessor.setCursorAccessor(
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 5506
diff changeset
   191
            new AWTAccessor.CursorAccessor() {
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 5506
diff changeset
   192
                public long getPData(Cursor cursor) {
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 5506
diff changeset
   193
                    return cursor.pData;
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 5506
diff changeset
   194
                }
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 5506
diff changeset
   195
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 5506
diff changeset
   196
                public void setPData(Cursor cursor, long pData) {
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 5506
diff changeset
   197
                    cursor.pData = pData;
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 5506
diff changeset
   198
                }
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 5506
diff changeset
   199
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 5506
diff changeset
   200
                public int getType(Cursor cursor) {
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 5506
diff changeset
   201
                    return cursor.type;
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 5506
diff changeset
   202
                }
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 5506
diff changeset
   203
            });
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * Initialize JNI field and method IDs for fields that may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * accessed from C.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    private static native void initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * Hook into native data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    private transient long pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    private transient Object anchor = new Object();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    static class CursorDisposer implements sun.java2d.DisposerRecord {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        volatile long pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        public CursorDisposer(long pData) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            this.pData = pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        public void dispose() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
            if (pData != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                finalizeImpl(pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    transient CursorDisposer disposer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    private void setPData(long pData) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        this.pData = pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        if (GraphicsEnvironment.isHeadless()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        if (disposer == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
            disposer = new CursorDisposer(pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
            // anchor is null after deserialization
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            if (anchor == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
                anchor = new Object();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
            sun.java2d.Disposer.addRecord(anchor, disposer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
            disposer.pData = pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * The user-visible name of the cursor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * @see #getName()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    protected String name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * Returns a cursor object with the specified predefined type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * @param type the type of predefined cursor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * @return the specified predefined cursor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * @throws IllegalArgumentException if the specified cursor type is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     *         invalid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    static public Cursor getPredefinedCursor(int type) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        if (type < Cursor.DEFAULT_CURSOR || type > Cursor.MOVE_CURSOR) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
            throw new IllegalArgumentException("illegal cursor type");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        }
3445
39d00a6cac5e 6656586: Cursor.predefined is protected static mutable (findbugs)
art
parents: 2
diff changeset
   268
        Cursor c = predefinedPrivate[type];
39d00a6cac5e 6656586: Cursor.predefined is protected static mutable (findbugs)
art
parents: 2
diff changeset
   269
        if (c == null) {
39d00a6cac5e 6656586: Cursor.predefined is protected static mutable (findbugs)
art
parents: 2
diff changeset
   270
            predefinedPrivate[type] = c = new Cursor(type);
39d00a6cac5e 6656586: Cursor.predefined is protected static mutable (findbugs)
art
parents: 2
diff changeset
   271
        }
39d00a6cac5e 6656586: Cursor.predefined is protected static mutable (findbugs)
art
parents: 2
diff changeset
   272
        // fill 'predefined' array for backwards compatibility.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        if (predefined[type] == null) {
3445
39d00a6cac5e 6656586: Cursor.predefined is protected static mutable (findbugs)
art
parents: 2
diff changeset
   274
            predefined[type] = c;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        }
3445
39d00a6cac5e 6656586: Cursor.predefined is protected static mutable (findbugs)
art
parents: 2
diff changeset
   276
        return c;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * Returns a system-specific custom cursor object matching the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * specified name.  Cursor names are, for example: "Invalid.16x16"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * @param name a string describing the desired system-specific custom cursor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     * @return the system specific custom cursor named
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     * @exception HeadlessException if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     * <code>GraphicsEnvironment.isHeadless</code> returns true
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 23010
diff changeset
   287
     * @exception AWTException in case of erroneous retrieving of the cursor
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    static public Cursor getSystemCustomCursor(final String name)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        throws AWTException, HeadlessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        GraphicsEnvironment.checkHeadless();
15994
5c8a3d840366 8007295: Reduce number of warnings in awt classes
mcherkas
parents: 13604
diff changeset
   292
        Cursor cursor = systemCustomCursors.get(name);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        if (cursor == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
            synchronized(systemCustomCursors) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
                if (systemCustomCursorProperties == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
                    loadSystemCustomCursorProperties();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
29255
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
   300
            String prefix = CURSOR_DOT_PREFIX + name;
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
   301
            String key    = prefix + DOT_FILE_SUFFIX;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
            if (!systemCustomCursorProperties.containsKey(key)) {
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 15994
diff changeset
   304
                if (log.isLoggable(PlatformLogger.Level.FINER)) {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3711
diff changeset
   305
                    log.finer("Cursor.getSystemCustomCursor(" + name + ") returned null");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
            final String fileName =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
                systemCustomCursorProperties.getProperty(key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
29255
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
   313
            final String localized = systemCustomCursorProperties.getProperty(
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
   314
                    prefix + DOT_NAME_SUFFIX, name);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
29255
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
   316
            String hotspot = systemCustomCursorProperties.getProperty(prefix + DOT_HOTSPOT_SUFFIX);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
            if (hotspot == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
                throw new AWTException("no hotspot property defined for cursor: " + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
            StringTokenizer st = new StringTokenizer(hotspot, ",");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
            if (st.countTokens() != 2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
                throw new AWTException("failed to parse hotspot property for cursor: " + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
29255
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
   326
            final Point hotPoint;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
            try {
29255
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
   328
                hotPoint = new Point(Integer.parseInt(st.nextToken()),
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
   329
                                     Integer.parseInt(st.nextToken()));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
            } catch (NumberFormatException nfe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
                throw new AWTException("failed to parse hotspot property for cursor: " + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
            try {
29255
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
   335
                final Toolkit toolkit = Toolkit.getDefaultToolkit();
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
   336
                final String file = RESOURCE_PREFIX + fileName;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
29255
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
   338
                cursor = AccessController.doPrivileged(
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
   339
                        (PrivilegedExceptionAction<Cursor>) () -> {
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
   340
                            URL url = Cursor.class.getResource(file);
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
   341
                            Image image = toolkit.getImage(url);
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
   342
                            return toolkit.createCustomCursor(image, hotPoint,
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
   343
                                                              localized);
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
   344
                        });
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
            } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
                throw new AWTException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
                    "Exception: " + e.getClass() + " " + e.getMessage() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
                    " occurred while creating cursor " + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
            if (cursor == null) {
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 15994
diff changeset
   352
                if (log.isLoggable(PlatformLogger.Level.FINER)) {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3711
diff changeset
   353
                    log.finer("Cursor.getSystemCustomCursor(" + name + ") returned null");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
                systemCustomCursors.put(name, cursor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        return cursor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     * Return the system default cursor.
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 23010
diff changeset
   365
     *
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 23010
diff changeset
   366
     * @return the default cursor
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    static public Cursor getDefaultCursor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        return getPredefinedCursor(Cursor.DEFAULT_CURSOR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * Creates a new cursor object with the specified type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     * @param type the type of cursor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     * @throws IllegalArgumentException if the specified cursor type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     * is invalid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    @ConstructorProperties({"type"})
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
    public Cursor(int type) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        if (type < Cursor.DEFAULT_CURSOR || type > Cursor.MOVE_CURSOR) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
            throw new IllegalArgumentException("illegal cursor type");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        this.type = type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        // Lookup localized name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
        name = Toolkit.getProperty(cursorProperties[type][0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
                                   cursorProperties[type][1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     * Creates a new custom cursor object with the specified name.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     * Note:  this constructor should only be used by AWT implementations
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     * as part of their support for custom cursors.  Applications should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     * use Toolkit.createCustomCursor().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     * @param name the user-visible name of the cursor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     * @see java.awt.Toolkit#createCustomCursor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    protected Cursor(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
        this.type = Cursor.CUSTOM_CURSOR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        this.name = name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     * Returns the type for this cursor.
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 23010
diff changeset
   405
     *
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 23010
diff changeset
   406
     * @return the cursor type
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    public int getType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
        return type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * Returns the name of this cursor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     * @return    a localized description of this cursor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     * @since     1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
    public String getName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
        return name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     * Returns a string representation of this cursor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     * @return    a string representation of this cursor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
     * @since     1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
        return getClass().getName() + "[" + getName() + "]";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * load the cursor.properties file
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
    private static void loadSystemCustomCursorProperties() throws AWTException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
        synchronized(systemCustomCursors) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
            systemCustomCursorProperties = new Properties();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
            try {
29255
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
   438
                AccessController.doPrivileged(
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
   439
                        (PrivilegedExceptionAction<Object>) () -> {
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
   440
                            try (InputStream is = Cursor.class
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
   441
                                    .getResourceAsStream(PROPERTIES_FILE)) {
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
   442
                                systemCustomCursorProperties.load(is);
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
   443
                            }
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
   444
                            return null;
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
   445
                        });
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
            } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
                systemCustomCursorProperties = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
                 throw new AWTException("Exception: " + e.getClass() + " " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
                   e.getMessage() + " occurred while loading: " +
29255
0989118f6e69 8039269: images/cursors should not be in ${java.home}/lib
serb
parents: 25859
diff changeset
   450
                   PROPERTIES_FILE);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
    private native static void finalizeImpl(long pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
}