Mega Code Archive

 
Categories / Java Tutorial / Swing
 

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);   } }