< prev index next >

src/java.desktop/share/classes/java/awt/Cursor.java

Print this page




 129     /* Localization names and default values */
 130     static final String[][] cursorProperties = {
 131         { "AWT.DefaultCursor", "Default Cursor" },
 132         { "AWT.CrosshairCursor", "Crosshair Cursor" },
 133         { "AWT.TextCursor", "Text Cursor" },
 134         { "AWT.WaitCursor", "Wait Cursor" },
 135         { "AWT.SWResizeCursor", "Southwest Resize Cursor" },
 136         { "AWT.SEResizeCursor", "Southeast Resize Cursor" },
 137         { "AWT.NWResizeCursor", "Northwest Resize Cursor" },
 138         { "AWT.NEResizeCursor", "Northeast Resize Cursor" },
 139         { "AWT.NResizeCursor", "North Resize Cursor" },
 140         { "AWT.SResizeCursor", "South Resize Cursor" },
 141         { "AWT.WResizeCursor", "West Resize Cursor" },
 142         { "AWT.EResizeCursor", "East Resize Cursor" },
 143         { "AWT.HandCursor", "Hand Cursor" },
 144         { "AWT.MoveCursor", "Move Cursor" },
 145     };
 146 
 147     /**
 148      * The chosen cursor type initially set to
 149      * the <code>DEFAULT_CURSOR</code>.
 150      *
 151      * @serial
 152      * @see #getType()
 153      */
 154     int type = DEFAULT_CURSOR;
 155 
 156     /**
 157      * The type associated with all custom cursors.
 158      */
 159     public static final int     CUSTOM_CURSOR                   = -1;
 160 
 161     /*
 162      * hashtable, resource prefix, filename, and properties for custom cursors
 163      * support
 164      */
 165     private static final Hashtable<String,Cursor> systemCustomCursors = new Hashtable<>(1);
 166     private static final String RESOURCE_PREFIX = "/sun/awt/resources/cursors/";
 167     private static final String PROPERTIES_FILE = RESOURCE_PREFIX + "cursors.properties";
 168 
 169     private static       Properties systemCustomCursorProperties = null;


 266             throw new IllegalArgumentException("illegal cursor type");
 267         }
 268         Cursor c = predefinedPrivate[type];
 269         if (c == null) {
 270             predefinedPrivate[type] = c = new Cursor(type);
 271         }
 272         // fill 'predefined' array for backwards compatibility.
 273         if (predefined[type] == null) {
 274             predefined[type] = c;
 275         }
 276         return c;
 277     }
 278 
 279     /**
 280      * Returns a system-specific custom cursor object matching the
 281      * specified name.  Cursor names are, for example: "Invalid.16x16"
 282      *
 283      * @param name a string describing the desired system-specific custom cursor
 284      * @return the system specific custom cursor named
 285      * @exception HeadlessException if
 286      * <code>GraphicsEnvironment.isHeadless</code> returns true
 287      * @exception AWTException in case of erroneous retrieving of the cursor
 288      */
 289     public static Cursor getSystemCustomCursor(final String name)
 290         throws AWTException, HeadlessException {
 291         GraphicsEnvironment.checkHeadless();
 292         Cursor cursor = systemCustomCursors.get(name);
 293 
 294         if (cursor == null) {
 295             synchronized(systemCustomCursors) {
 296                 if (systemCustomCursorProperties == null)
 297                     loadSystemCustomCursorProperties();
 298             }
 299 
 300             String prefix = CURSOR_DOT_PREFIX + name;
 301             String key    = prefix + DOT_FILE_SUFFIX;
 302 
 303             if (!systemCustomCursorProperties.containsKey(key)) {
 304                 if (log.isLoggable(PlatformLogger.Level.FINER)) {
 305                     log.finer("Cursor.getSystemCustomCursor(" + name + ") returned null");
 306                 }




 129     /* Localization names and default values */
 130     static final String[][] cursorProperties = {
 131         { "AWT.DefaultCursor", "Default Cursor" },
 132         { "AWT.CrosshairCursor", "Crosshair Cursor" },
 133         { "AWT.TextCursor", "Text Cursor" },
 134         { "AWT.WaitCursor", "Wait Cursor" },
 135         { "AWT.SWResizeCursor", "Southwest Resize Cursor" },
 136         { "AWT.SEResizeCursor", "Southeast Resize Cursor" },
 137         { "AWT.NWResizeCursor", "Northwest Resize Cursor" },
 138         { "AWT.NEResizeCursor", "Northeast Resize Cursor" },
 139         { "AWT.NResizeCursor", "North Resize Cursor" },
 140         { "AWT.SResizeCursor", "South Resize Cursor" },
 141         { "AWT.WResizeCursor", "West Resize Cursor" },
 142         { "AWT.EResizeCursor", "East Resize Cursor" },
 143         { "AWT.HandCursor", "Hand Cursor" },
 144         { "AWT.MoveCursor", "Move Cursor" },
 145     };
 146 
 147     /**
 148      * The chosen cursor type initially set to
 149      * the {@code DEFAULT_CURSOR}.
 150      *
 151      * @serial
 152      * @see #getType()
 153      */
 154     int type = DEFAULT_CURSOR;
 155 
 156     /**
 157      * The type associated with all custom cursors.
 158      */
 159     public static final int     CUSTOM_CURSOR                   = -1;
 160 
 161     /*
 162      * hashtable, resource prefix, filename, and properties for custom cursors
 163      * support
 164      */
 165     private static final Hashtable<String,Cursor> systemCustomCursors = new Hashtable<>(1);
 166     private static final String RESOURCE_PREFIX = "/sun/awt/resources/cursors/";
 167     private static final String PROPERTIES_FILE = RESOURCE_PREFIX + "cursors.properties";
 168 
 169     private static       Properties systemCustomCursorProperties = null;


 266             throw new IllegalArgumentException("illegal cursor type");
 267         }
 268         Cursor c = predefinedPrivate[type];
 269         if (c == null) {
 270             predefinedPrivate[type] = c = new Cursor(type);
 271         }
 272         // fill 'predefined' array for backwards compatibility.
 273         if (predefined[type] == null) {
 274             predefined[type] = c;
 275         }
 276         return c;
 277     }
 278 
 279     /**
 280      * Returns a system-specific custom cursor object matching the
 281      * specified name.  Cursor names are, for example: "Invalid.16x16"
 282      *
 283      * @param name a string describing the desired system-specific custom cursor
 284      * @return the system specific custom cursor named
 285      * @exception HeadlessException if
 286      * {@code GraphicsEnvironment.isHeadless} returns true
 287      * @exception AWTException in case of erroneous retrieving of the cursor
 288      */
 289     public static Cursor getSystemCustomCursor(final String name)
 290         throws AWTException, HeadlessException {
 291         GraphicsEnvironment.checkHeadless();
 292         Cursor cursor = systemCustomCursors.get(name);
 293 
 294         if (cursor == null) {
 295             synchronized(systemCustomCursors) {
 296                 if (systemCustomCursorProperties == null)
 297                     loadSystemCustomCursorProperties();
 298             }
 299 
 300             String prefix = CURSOR_DOT_PREFIX + name;
 301             String key    = prefix + DOT_FILE_SUFFIX;
 302 
 303             if (!systemCustomCursorProperties.containsKey(key)) {
 304                 if (log.isLoggable(PlatformLogger.Level.FINER)) {
 305                     log.finer("Cursor.getSystemCustomCursor(" + name + ") returned null");
 306                 }


< prev index next >