Fields Summary |
---|
public static final int | DEFAULT_CURSORThe default cursor type (gets set if no cursor is defined). |
public static final int | CROSSHAIR_CURSORThe crosshair cursor type. |
public static final int | TEXT_CURSORThe text cursor type. |
public static final int | WAIT_CURSORThe wait cursor type. |
public static final int | SW_RESIZE_CURSORThe south-west-resize cursor type. |
public static final int | SE_RESIZE_CURSORThe south-east-resize cursor type. |
public static final int | NW_RESIZE_CURSORThe north-west-resize cursor type. |
public static final int | NE_RESIZE_CURSORThe north-east-resize cursor type. |
public static final int | N_RESIZE_CURSORThe north-resize cursor type. |
public static final int | S_RESIZE_CURSORThe south-resize cursor type. |
public static final int | W_RESIZE_CURSORThe west-resize cursor type. |
public static final int | E_RESIZE_CURSORThe east-resize cursor type. |
public static final int | HAND_CURSORThe hand cursor type. |
public static final int | MOVE_CURSORThe move cursor type. |
protected static Cursor[] | predefined |
static final String[] | cursorProperties |
int | typeThe chosen cursor type initially set to
the DEFAULT_CURSOR . |
public static final int | CUSTOM_CURSORThe type associated with all custom cursors. |
private static final Hashtable | systemCustomCursors |
private static final String | systemCustomCursorDirPrefix |
private static final String | systemCustomCursorPropertiesFile |
private static Properties | systemCustomCursorProperties |
private static final String | CursorDotPrefix |
private static final String | DotFileSuffix |
private static final String | DotHotspotSuffix |
private static final String | DotNameSuffix |
private static final long | serialVersionUID |
private static final sun.awt.DebugHelper | dbg |
private transient long | pDataHook into native data. |
private transient Object | anchor |
transient CursorDisposer | disposer |
protected String | nameThe user-visible name of the cursor. |
Methods Summary |
---|
private static native void | finalizeImpl(long pData)
|
public static java.awt.Cursor | getDefaultCursor()Return the system default cursor.
return getPredefinedCursor(Cursor.DEFAULT_CURSOR);
|
public java.lang.String | getName()Returns the name of this cursor.
return name;
|
public static java.awt.Cursor | getPredefinedCursor(int type)Returns a cursor object with the specified predefined type.
if (type < Cursor.DEFAULT_CURSOR || type > Cursor.MOVE_CURSOR) {
throw new IllegalArgumentException("illegal cursor type");
}
if (predefined[type] == null) {
predefined[type] = new Cursor(type);
}
return predefined[type];
|
public static java.awt.Cursor | getSystemCustomCursor(java.lang.String name)Returns a system-specific custom cursor object matching the
specified name. Cursor names are, for example: "Invalid.16x16"
GraphicsEnvironment.checkHeadless();
Cursor cursor = (Cursor)systemCustomCursors.get(name);
if (cursor == null) {
synchronized(systemCustomCursors) {
if (systemCustomCursorProperties == null)
loadSystemCustomCursorProperties();
}
String prefix = CursorDotPrefix + name;
String key = prefix + DotFileSuffix;
if (!systemCustomCursorProperties.containsKey(key)) {
if (dbg.on) {
dbg.println("Cursor.getSystemCustomCursor(" + name + ") returned null");
}
return null;
}
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, ",");
if (st.countTokens() != 2)
throw new AWTException("failed to parse hotspot property for cursor: " + name);
int x = 0;
int y = 0;
try {
x = Integer.parseInt(st.nextToken());
y = Integer.parseInt(st.nextToken());
} catch (NumberFormatException nfe) {
throw new AWTException("failed to parse hotspot property for cursor: " + name);
}
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);
}
});
} catch (Exception e) {
throw new AWTException(
"Exception: " + e.getClass() + " " + e.getMessage() +
" occurred while creating cursor " + name);
}
if (cursor == null) {
if (dbg.on) {
dbg.println("Cursor.getSystemCustomCursor(" + name + ") returned null");
}
} else {
systemCustomCursors.put(name, cursor);
}
}
return cursor;
|
public int | getType()Returns the type for this cursor.
return type;
|
private static java.lang.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;
|
private static native void | initIDs()Initialize JNI field and method IDs for fields that may be
accessed from C.
|
private static void | loadSystemCustomCursorProperties()
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);
systemCustomCursorProperties.load(fis);
} finally {
if (fis != null)
fis.close();
}
return null;
}
});
} catch (Exception e) {
systemCustomCursorProperties = null;
throw new AWTException("Exception: " + e.getClass() + " " +
e.getMessage() + " occurred while loading: " +
systemCustomCursorPropertiesFile);
}
}
|
private void | setPData(long pData)
this.pData = pData;
if (GraphicsEnvironment.isHeadless()) {
return;
}
if (disposer == null) {
disposer = new CursorDisposer(pData);
// anchor is null after deserialization
if (anchor == null) {
anchor = new Object();
}
sun.java2d.Disposer.addRecord(anchor, disposer);
} else {
disposer.pData = pData;
}
|
public java.lang.String | toString()Returns a string representation of this cursor.
return getClass().getName() + "[" + getName() + "]";
|