Create Cursor from an Image : SWT Cursor « SWT « Java Tutorial






import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class CursorImageCreate {

  public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setSize(150, 150);
    
    Cursor cursor = new Cursor(display, new Image(display,"yourFile.gif").getImageData(), 0, 0);
    shell.setCursor(cursor);

    shell.open();
    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