Example usage for org.eclipse.swt.widgets Button setCursor

List of usage examples for org.eclipse.swt.widgets Button setCursor

Introduction

In this page you can find the example usage for org.eclipse.swt.widgets Button setCursor.

Prototype

public void setCursor(Cursor cursor) 

Source Link

Document

Sets the receiver's cursor to the cursor specified by the argument, or to the default cursor for that kind of control if the argument is null.

Usage

From source file:CursorSetControl.java

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();//w ww  .  jav  a 2 s. c  o  m
    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();
}

From source file:Snippet44.java

public static void main(String[] args) {
    Display display = new Display();
    final Cursor cursor = new Cursor(display, SWT.CURSOR_HAND);
    Shell shell = new Shell(display);
    shell.open();/* ww w .  j  a  v a 2 s  .c  om*/
    final Button b = new Button(shell, 0);
    b.setBounds(10, 10, 200, 200);
    b.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event e) {
            b.setCursor(cursor);
        }
    });
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    cursor.dispose();
    display.dispose();
}

From source file:org.eclipse.swt.snippets.Snippet44.java

public static void main(String[] args) {
    Display display = new Display();
    final Cursor cursor = display.getSystemCursor(SWT.CURSOR_HAND);
    Shell shell = new Shell(display);
    shell.setText("Snippet 44");
    shell.open();//w w  w.j  av  a  2  s .  com
    final Button b = new Button(shell, 0);
    b.setText("Push to set cursor to hand");
    Rectangle clientArea = shell.getClientArea();
    b.setBounds(clientArea.x + 10, clientArea.y + 10, 200, 200);
    b.addListener(SWT.Selection, e -> b.setCursor(cursor));
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}