Example usage for java.awt Cursor getDefaultCursor

List of usage examples for java.awt Cursor getDefaultCursor

Introduction

In this page you can find the example usage for java.awt Cursor getDefaultCursor.

Prototype

public static Cursor getDefaultCursor() 

Source Link

Document

Return the system default cursor.

Usage

From source file:Main.java

public static void main(String[] args) {

    System.out.println(Cursor.getDefaultCursor().getType());
}

From source file:Main.java

public static void main(String[] args) {
    JFrame aWindow = new JFrame();
    aWindow.setBounds(200, 200, 200, 200);
    aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    aWindow.setCursor(Cursor.getDefaultCursor());
    aWindow.setVisible(true);/*from ww w. j  a va  2  s . co  m*/
}

From source file:Main.java

public static void main(String[] args) {
    JFrame aWindow = new JFrame();
    aWindow.setBounds(200, 200, 200, 200);
    aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    aWindow.setCursor(Cursor.getDefaultCursor());
    aWindow.setVisible(true);/*  w  ww .  j  a v  a 2s.  co  m*/

    System.out.println(Cursor.getDefaultCursor().getName());
}

From source file:Main.java

public static final void main(String[] args) throws Exception {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JTextPane textPane = new JTextPane();
    textPane.addMouseMotionListener(new MouseAdapter() {
        public void mouseMoved(MouseEvent e) {
            AttributeSet style = getAttributes(e);
            if (style != null && StyleConstants.getIcon(style) != null) {
                textPane.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            } else {
                textPane.setCursor(Cursor.getDefaultCursor());
            }//from  w ww .j a  v  a2  s .  c  o  m
        }
    });
    frame.add(new JScrollPane(textPane));

    StyledDocument doc = (StyledDocument) textPane.getDocument();

    SimpleAttributeSet style = new SimpleAttributeSet();
    StyleConstants.setIcon(style, createImage());

    doc.insertString(doc.getLength(), "this is a test", null);
    doc.insertString(doc.getLength(), "test", style);
    doc.insertString(doc.getLength(), "this is a test\n", null);
    doc.insertString(doc.getLength(), "another image", style);

    frame.pack();
    frame.setLocationByPlatform(true);
    frame.setVisible(true);

}

From source file:Main.java

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

From source file:Main.java

private MouseListener getListener() {
    return new MouseAdapter() {
        @Override//  w w  w .  j  av a  2s  . co m
        public void mousePressed(MouseEvent e) {
            super.mousePressed(e);
            pane.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            super.mouseReleased(e);
            pane.setCursor(Cursor.getDefaultCursor());
        }
    };
}

From source file:net.sf.nmedit.jtheme.JTCursor.java

private static Cursor createCursor(int id) {
    Toolkit tk = Toolkit.getDefaultToolkit();
    URL res = getResource(id);//from  w ww  . j a va  2s  .  c om

    if (res == null) {
        Log log = LogFactory.getLog(JTCursor.class);
        if (log.isWarnEnabled()) {
            log.warn("Could not find cursor: id=" + id + ", url=" + res);
        }
        return Cursor.getDefaultCursor();
    }

    Image img;
    try {
        img = ImageIO.read(res);
    } catch (IOException e) {
        Log log = LogFactory.getLog(JTCursor.class);
        if (log.isWarnEnabled()) {
            log.warn("Could not find cursor: id=" + id + ", url=" + res, e);
        }
        return Cursor.getDefaultCursor();
    }

    return tk.createCustomCursor(img, new Point(4, 16), names[id]);
}

From source file:URLLabel.java

public void mouseExited(MouseEvent e) {
    setCursor(Cursor.getDefaultCursor());
    entered = false;

    if (mousehover) {
        repaint();
    }
}

From source file:com.igormaznitsa.zxpoly.ui.AboutDialog.java

public AboutDialog(final java.awt.Frame parent) {
    super(parent, true);
    initComponents();/*from w  w  w  .  j av  a  2s .com*/

    this.editorPane.addHyperlinkListener(new HyperlinkListener() {

        @Override
        public void hyperlinkUpdate(final HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                try {
                    Desktop.getDesktop().browse(e.getURL().toURI());
                } catch (Exception ex) {
                }
            } else if (e.getEventType() == HyperlinkEvent.EventType.ENTERED) {
                editorPane.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            } else if (e.getEventType() == HyperlinkEvent.EventType.EXITED) {
                editorPane.setCursor(Cursor.getDefaultCursor());
            }
        }
    });

    this.editorPane.setContentType("text/html");
    try {
        final String htmlText = IOUtils.toString(openAboutResource("index.html"), "UTF-8");
        this.editorPane.setText(htmlText);
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    setLocationRelativeTo(parent);
}

From source file:ste.travian.gui.WorldChartPanel.java

@Override
public void chartProgress(ChartProgressEvent event) {

    if (event.getType() == ChartProgressEvent.DRAWING_STARTED) {
        mainWindow.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    } else {//from w  w  w .  jav  a 2  s  . c o  m
        mainWindow.setCursor(Cursor.getDefaultCursor());
    }
}