src/share/classes/java/awt/Cursor.java
Print this page
*** 161,175 ****
/*
* hashtable, filesystem dir prefix, filename, and properties for custom cursors support
*/
! private static final Hashtable systemCustomCursors = new Hashtable(1);
private static final String systemCustomCursorDirPrefix = initCursorDir();
private static String initCursorDir() {
! String jhome = (String) java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("java.home"));
return jhome +
File.separator + "lib" + File.separator + "images" +
File.separator + "cursors" + File.separator;
}
--- 161,175 ----
/*
* hashtable, filesystem dir prefix, filename, and properties for custom cursors support
*/
! private static final Hashtable<String,Cursor> systemCustomCursors = new Hashtable<>(1);
private static final String systemCustomCursorDirPrefix = initCursorDir();
private static String initCursorDir() {
! String jhome = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("java.home"));
return jhome +
File.separator + "lib" + File.separator + "images" +
File.separator + "cursors" + File.separator;
}
*** 296,306 ****
* <code>GraphicsEnvironment.isHeadless</code> returns true
*/
static public Cursor getSystemCustomCursor(final String name)
throws AWTException, HeadlessException {
GraphicsEnvironment.checkHeadless();
! Cursor cursor = (Cursor)systemCustomCursors.get(name);
if (cursor == null) {
synchronized(systemCustomCursors) {
if (systemCustomCursorProperties == null)
loadSystemCustomCursorProperties();
--- 296,306 ----
* <code>GraphicsEnvironment.isHeadless</code> returns true
*/
static public Cursor getSystemCustomCursor(final String name)
throws AWTException, HeadlessException {
GraphicsEnvironment.checkHeadless();
! Cursor cursor = systemCustomCursors.get(name);
if (cursor == null) {
synchronized(systemCustomCursors) {
if (systemCustomCursorProperties == null)
loadSystemCustomCursorProperties();
*** 317,331 ****
}
final String fileName =
systemCustomCursorProperties.getProperty(key);
! String localized = (String)systemCustomCursorProperties.getProperty(prefix + DotNameSuffix);
if (localized == null) localized = name;
! String hotspot = (String)systemCustomCursorProperties.getProperty(prefix + DotHotspotSuffix);
if (hotspot == null)
throw new AWTException("no hotspot property defined for cursor: " + name);
StringTokenizer st = new StringTokenizer(hotspot, ",");
--- 317,331 ----
}
final String fileName =
systemCustomCursorProperties.getProperty(key);
! String localized = systemCustomCursorProperties.getProperty(prefix + DotNameSuffix);
if (localized == null) localized = name;
! String hotspot = systemCustomCursorProperties.getProperty(prefix + DotHotspotSuffix);
if (hotspot == null)
throw new AWTException("no hotspot property defined for cursor: " + name);
StringTokenizer st = new StringTokenizer(hotspot, ",");
*** 346,358 ****
try {
final int fx = x;
final int fy = y;
final String flocalized = localized;
! cursor = (Cursor) java.security.AccessController.doPrivileged(
! new java.security.PrivilegedExceptionAction() {
! public Object run() throws Exception {
Toolkit toolkit = Toolkit.getDefaultToolkit();
Image image = toolkit.getImage(
systemCustomCursorDirPrefix + fileName);
return toolkit.createCustomCursor(
image, new Point(fx,fy), flocalized);
--- 346,358 ----
try {
final int fx = x;
final int fy = y;
final String flocalized = localized;
! cursor = java.security.AccessController.<Cursor>doPrivileged(
! new java.security.PrivilegedExceptionAction<Cursor>() {
! public Cursor run() throws Exception {
Toolkit toolkit = Toolkit.getDefaultToolkit();
Image image = toolkit.getImage(
systemCustomCursorDirPrefix + fileName);
return toolkit.createCustomCursor(
image, new Point(fx,fy), flocalized);
*** 445,456 ****
private static void loadSystemCustomCursorProperties() throws AWTException {
synchronized(systemCustomCursors) {
systemCustomCursorProperties = new Properties();
try {
! AccessController.doPrivileged(
! new java.security.PrivilegedExceptionAction() {
public Object run() throws Exception {
FileInputStream fis = null;
try {
fis = new FileInputStream(
systemCustomCursorPropertiesFile);
--- 445,456 ----
private static void loadSystemCustomCursorProperties() throws AWTException {
synchronized(systemCustomCursors) {
systemCustomCursorProperties = new Properties();
try {
! AccessController.<Object>doPrivileged(
! new java.security.PrivilegedExceptionAction<Object>() {
public Object run() throws Exception {
FileInputStream fis = null;
try {
fis = new FileInputStream(
systemCustomCursorPropertiesFile);