Changing the Cursor : Cursor « Swing JFC « Java






Changing the Cursor

  

import java.awt.Button;
import java.awt.Component;
import java.awt.Cursor;

import javax.swing.JFrame;

public class Main {
  public static void main() {
    Component comp = new Button("OK");

    Cursor cursor = comp.getCursor();

    comp.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

    JFrame frame = new JFrame();
    frame.add(comp);
    frame.setSize(300, 300);
    frame.setVisible(true);
  }
}

   
    
  








Related examples in the same category

1.Change the cursor shape
2.Change Cursor in a thread for animation
3.Cursor Util