Example usage for java.awt Component setCursor

List of usage examples for java.awt Component setCursor

Introduction

In this page you can find the example usage for java.awt Component setCursor.

Prototype

public void setCursor(Cursor cursor) 

Source Link

Document

Sets the cursor image to the specified cursor.

Usage

From source file:Main.java

public static void setWaitCursorFor(Component frame) {
    frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
}

From source file:Main.java

public static void setDefaultCursor(Component comp) {
    comp.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}

From source file:Main.java

/**
 * Set the mouse pointer for this component to the default system cursor
 * /*from   w  ww.  j  ava 2s .  c om*/
 * @param component
 */
public static void showPointer(Component component) {
    component.setCursor(Cursor.getDefaultCursor());
}

From source file:Main.java

public static void main() {
    Component comp = new Button("OK");

    Cursor cursor = comp.getCursor();

    comp.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

    JFrame frame = new JFrame();
    frame.add(comp);/* w  w w  .  j  a va 2s  .  co m*/
    frame.setSize(300, 300);
    frame.setVisible(true);
}

From source file:Main.java

/**
 * Don't show the mouse pointer for this component
 * @param component/*  w ww.j  a  v a 2s  . c o  m*/
 */
public static void hidePointer(Component component) {
    component.setCursor(emptyCursor);
}

From source file:Main.java

public static void setBusyCursor(Component comp, boolean busy) {
    if (busy) {//from  w  w w .j  a va  2 s  .com
        comp.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    } else {
        comp.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    }
}

From source file:GuiUtil.java

public static void setWaitCursor(Component c, boolean yesno) {
    c.setCursor(yesno ? waitCursor : defCursor);
    getFrame(c).setCursor(yesno ? waitCursor : defCursor);
}

From source file:Main.java

/**
 * Sets the cursor for the given component and all child components to the
 * given cursor.//w w w .  j a  v  a  2  s  .  com
 */
public static void setCursor(final Component c, final Cursor cursor) {
    if (c == null)
        return;
    c.setCursor(cursor);
    if (c instanceof JFrame)
        setCursor(((JFrame) c).getContentPane(), cursor);
    else if (c instanceof JDialog) {
        setCursor(((JDialog) c).getContentPane(), cursor);
    } else if (c instanceof Container) {
        final Container contain = (Container) c;
        final Component[] sub = contain.getComponents();
        for (int i = 0; i < sub.length; i++)
            setCursor(sub[i], cursor);
    }
}

From source file:Main.java

/**
 * Adds a hand cursor to the component, as well as a click listener that
 * triggers a browse action to the given url.
 */// w w  w.jav  a2  s .  com
public static void addBrowseBehavior(final Component cmp, final String url) {
    if (url == null)
        return;
    cmp.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    cmp.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            JFrame frame = getJFrame(cmp);
            browse(url, frame);
        }
    });
}

From source file:Main.java

/**
 * Adds a hand cursor to the component, as well as a click listener that
 * triggers a browse action to the given url.
 *///  ww w . ja  v a 2s. c  o m
public static void addBrowseBehavior(final Component cmp, final String url) {
    if (url == null) {
        return;
    }
    cmp.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    cmp.addMouseListener(new MouseAdapter() {

        @Override
        public void mousePressed(MouseEvent e) {
            JFrame frame = getJFrame(cmp);
            browse(url, frame);
        }
    });
}