public class

Cursor

extends Object
implements Serializable
java.lang.Object
   ↳ java.awt.Cursor
Known Direct Subclasses

Class Overview

A class to encapsulate the bitmap representation of the mouse cursor.

Summary

Constants
int CROSSHAIR_CURSOR The crosshair cursor type.
int CUSTOM_CURSOR The type associated with all custom cursors.
int DEFAULT_CURSOR The default cursor type (gets set if no cursor is defined).
int E_RESIZE_CURSOR The east-resize cursor type.
int HAND_CURSOR The hand cursor type.
int MOVE_CURSOR The move cursor type.
int NE_RESIZE_CURSOR The north-east-resize cursor type.
int NW_RESIZE_CURSOR The north-west-resize cursor type.
int N_RESIZE_CURSOR The north-resize cursor type.
int SE_RESIZE_CURSOR The south-east-resize cursor type.
int SW_RESIZE_CURSOR The south-west-resize cursor type.
int S_RESIZE_CURSOR The south-resize cursor type.
int TEXT_CURSOR The text cursor type.
int WAIT_CURSOR The wait cursor type.
int W_RESIZE_CURSOR The west-resize cursor type.
Fields
protected String name The user-visible name of the cursor.@serial
protected static Cursor[] predefined
Public Constructors
Cursor(int type)
Creates a new cursor object with the specified type.
Protected Constructors
Cursor(String name)
Creates a new custom cursor object with the specified name.
Public Methods
static Cursor getDefaultCursor()
Return the system default cursor.
String getName()
Returns the name of this cursor.
static Cursor getPredefinedCursor(int type)
Returns a cursor object with the specified predefined type.
static Cursor getSystemCustomCursor(String name)
Returns a system-specific custom cursor object matching the specified name.
int getType()
Returns the type for this cursor.
String toString()
Returns a string representation of this cursor.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int CROSSHAIR_CURSOR

The crosshair cursor type.

Constant Value: 1 (0x00000001)

public static final int CUSTOM_CURSOR

The type associated with all custom cursors.

Constant Value: -1 (0xffffffff)

public static final int DEFAULT_CURSOR

The default cursor type (gets set if no cursor is defined).

Constant Value: 0 (0x00000000)

public static final int E_RESIZE_CURSOR

The east-resize cursor type.

Constant Value: 11 (0x0000000b)

public static final int HAND_CURSOR

The hand cursor type.

Constant Value: 12 (0x0000000c)

public static final int MOVE_CURSOR

The move cursor type.

Constant Value: 13 (0x0000000d)

public static final int NE_RESIZE_CURSOR

The north-east-resize cursor type.

Constant Value: 7 (0x00000007)

public static final int NW_RESIZE_CURSOR

The north-west-resize cursor type.

Constant Value: 6 (0x00000006)

public static final int N_RESIZE_CURSOR

The north-resize cursor type.

Constant Value: 8 (0x00000008)

public static final int SE_RESIZE_CURSOR

The south-east-resize cursor type.

Constant Value: 5 (0x00000005)

public static final int SW_RESIZE_CURSOR

The south-west-resize cursor type.

Constant Value: 4 (0x00000004)

public static final int S_RESIZE_CURSOR

The south-resize cursor type.

Constant Value: 9 (0x00000009)

public static final int TEXT_CURSOR

The text cursor type.

Constant Value: 2 (0x00000002)

public static final int WAIT_CURSOR

The wait cursor type.

Constant Value: 3 (0x00000003)

public static final int W_RESIZE_CURSOR

The west-resize cursor type.

Constant Value: 10 (0x0000000a)

Fields

protected String name

The user-visible name of the cursor.@serial

See Also

protected static Cursor[] predefined

Public Constructors

public Cursor (int type)

Creates a new cursor object with the specified type.

Parameters
type the type of cursor
Throws
IllegalArgumentException if the specified cursor type is invalid

Protected Constructors

protected Cursor (String name)

Creates a new custom cursor object with the specified name.

Note: this constructor should only be used by AWT implementations as part of their support for custom cursors. Applications should use Toolkit.createCustomCursor().

Parameters
name the user-visible name of the cursor.

Public Methods

public static Cursor getDefaultCursor ()

Return the system default cursor.

public String getName ()

Returns the name of this cursor.

Returns
  • a localized description of this cursor.

public static Cursor getPredefinedCursor (int type)

Returns a cursor object with the specified predefined type.

Parameters
type the type of predefined cursor
Returns
  • the specified predefined cursor
Throws
IllegalArgumentException if the specified cursor type is invalid

public static Cursor getSystemCustomCursor (String name)

Returns a system-specific custom cursor object matching the specified name. Cursor names are, for example: "Invalid.16x16"

Parameters
name a string describing the desired system-specific custom cursor
Returns
  • the system specific custom cursor named
Throws
HeadlessException if GraphicsEnvironment.isHeadless returns true
AWTException

public int getType ()

Returns the type for this cursor.

public String toString ()

Returns a string representation of this cursor.

Returns
  • a string representation of this cursor.