CursorImageCreate.java Source code

Java tutorial

Introduction

Here is the source code for CursorImageCreate.java

Source

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