Java Swing Tutorial - Java Cursor CROSSHAIR_CURSOR








Syntax

Cursor.CROSSHAIR_CURSOR has the following syntax.

public static final int CROSSHAIR_CURSOR

Example

In the following code shows how to use Cursor.CROSSHAIR_CURSOR field.

/*  w  w w. j  ava  2  s.  co  m*/
import java.awt.Cursor;

import javax.swing.JFrame;

public class Main {
  public static void main(String[] args) {
    JFrame aWindow = new JFrame();
    aWindow.setBounds(200, 200, 200, 200);
    aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    aWindow.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
    aWindow.setVisible(true);
  }
}