Java Swing Tutorial - Java Cursor .getSystemCustomCursor (String name)








Syntax

Cursor.getSystemCustomCursor(String name) has the following syntax.

public static Cursor getSystemCustomCursor(String name)     throws AWTException ,      HeadlessException

Example

In the following code shows how to use Cursor.getSystemCustomCursor(String name) method.

/*w  w w  .  j a  v a  2 s . com*/
import java.awt.AWTException;
import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Cursor;
import java.awt.Frame;
import java.awt.HeadlessException;

public class Main {
  public static void main(String[] args) throws HeadlessException, AWTException {
    Frame frame = new Frame();
    Button button1 = new Button("Ok");
    frame.add(button1, BorderLayout.NORTH);
    frame.setSize(50, 55);
    frame.setVisible(true);
    
    button1.setCursor(Cursor.getSystemCustomCursor("MoveDrop.32x32"));
  }
}