Set Cursor to Control : SWT Cursor « SWT « Java Tutorial






import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class CursorSetControl {

  public static void main(String[] args) {
    Display display = new Display();
    
    Cursor cursor = new Cursor(display, SWT.CURSOR_HAND);
    
    Shell shell = new Shell(display);
    shell.open();
    final Button b = new Button(shell, 0);
    b.setBounds(10, 10, 200, 200);
    b.setCursor(cursor);
    
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch())
        display.sleep();
    }
    cursor.dispose();
    display.dispose();
  }
}








17.38.SWT Cursor
17.38.1.Create Cursor from an Image
17.38.2.Create a color cursor from a source and a maskCreate a color cursor from a source and a mask
17.38.3.Create a cursor from a source and a maskCreate a cursor from a source and a mask
17.38.4.Set Cursor to Control
17.38.5.Use transparent image to hide CursorUse transparent image to hide Cursor