Example usage for javax.swing JRootPane setCursor

List of usage examples for javax.swing JRootPane setCursor

Introduction

In this page you can find the example usage for javax.swing JRootPane setCursor.

Prototype

public void setCursor(Cursor cursor) 

Source Link

Document

Sets the cursor image to the specified cursor.

Usage

From source file:com.monead.semantic.workbench.SemanticWorkbench.java

/**
 * Sets the mouse pointer. If the supplied parameter is true then the wait
 * cursor (usually an hourglass) is displayed. otherwise the system default
 * cursor is displayed.//from   w w w .j ava2 s. co m
 * 
 * @param wait
 *          Whether to display the system default wait cursor
 */
private void setWaitCursor(boolean wait) {
    final JRootPane rootPane = getRootPane();
    final Component glassPane = rootPane.getGlassPane();

    if (wait) {
        final Cursor cursorWait = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
        rootPane.setCursor(cursorWait);
        glassPane.setCursor(cursorWait);
        glassPane.setVisible(true);
    } else {
        final Cursor cursorDefault = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
        glassPane.setVisible(false);
        glassPane.setCursor(cursorDefault);
        rootPane.setCursor(cursorDefault);
    }

    glassPane.invalidate();
    rootPane.validate();
}