src/share/classes/java/awt/Cursor.java
Print this page
@@ -161,15 +161,15 @@
/*
* hashtable, filesystem dir prefix, filename, and properties for custom cursors support
*/
- private static final Hashtable systemCustomCursors = new Hashtable(1);
+ private static final Hashtable<String,Cursor> systemCustomCursors = new Hashtable<>(1);
private static final String systemCustomCursorDirPrefix = initCursorDir();
private static String initCursorDir() {
- String jhome = (String) java.security.AccessController.doPrivileged(
+ 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,11 +296,11 @@
* <code>GraphicsEnvironment.isHeadless</code> returns true
*/
static public Cursor getSystemCustomCursor(final String name)
throws AWTException, HeadlessException {
GraphicsEnvironment.checkHeadless();
- Cursor cursor = (Cursor)systemCustomCursors.get(name);
+ Cursor cursor = systemCustomCursors.get(name);
if (cursor == null) {
synchronized(systemCustomCursors) {
if (systemCustomCursorProperties == null)
loadSystemCustomCursorProperties();
@@ -317,15 +317,15 @@
}
final String fileName =
systemCustomCursorProperties.getProperty(key);
- String localized = (String)systemCustomCursorProperties.getProperty(prefix + DotNameSuffix);
+ String localized = systemCustomCursorProperties.getProperty(prefix + DotNameSuffix);
if (localized == null) localized = name;
- String hotspot = (String)systemCustomCursorProperties.getProperty(prefix + DotHotspotSuffix);
+ 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,13 +346,13 @@
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 {
+ 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,12 +445,12 @@
private static void loadSystemCustomCursorProperties() throws AWTException {
synchronized(systemCustomCursors) {
systemCustomCursorProperties = new Properties();
try {
- AccessController.doPrivileged(
- new java.security.PrivilegedExceptionAction() {
+ AccessController.<Object>doPrivileged(
+ new java.security.PrivilegedExceptionAction<Object>() {
public Object run() throws Exception {
FileInputStream fis = null;
try {
fis = new FileInputStream(
systemCustomCursorPropertiesFile);