Example usage for java.awt Cursor Cursor

List of usage examples for java.awt Cursor Cursor

Introduction

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

Prototype

protected Cursor(String name) 

Source Link

Document

Creates a new custom cursor object with the specified name.

Note: this constructor should only be used by AWT implementations as part of their support for custom cursors.

Usage

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(new Cursor(Cursor.CROSSHAIR_CURSOR));
    aWindow.setVisible(true);/*w  w w  . ja  v a 2s  .  c o m*/
}

From source file:Main.java

public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            Main mainForm = new Main();
            mainForm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            mainForm.setSize(250, 250);/*from   w w w.  j av a  2 s. c  om*/

            Cursor cursor = new Cursor(Cursor.HAND_CURSOR);
            mainForm.setCursor(cursor);

            mainForm.pack();
            mainForm.setVisible(true);
        }
    });
}

From source file:org.pegadi.client.ApplicationLauncher.java

public static void main(String[] args) {
    com.sun.net.ssl.internal.ssl.Provider provider = new com.sun.net.ssl.internal.ssl.Provider();
    java.security.Security.addProvider(provider);
    setAllPermissions();/*from www.j a v a 2s  .  co  m*/
    /**
     * If we are on Apples operating system, we would like to use the screen
     * menu bar It is the first property we set in our main method. This is
     * to make sure that the property is set before awt is loaded.
     */
    if (System.getProperty("os.name").toLowerCase().startsWith("mac os x")) {
        System.setProperty("apple.laf.useScreenMenuBar", "true");
    }
    Logger log = LoggerFactory.getLogger(ApplicationLauncher.class);
    /**
     * Making sure default L&F is System
     */
    if (!UIManager.getLookAndFeel().getName().equals(UIManager.getSystemLookAndFeelClassName())) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception e) {
            log.warn("Unable to change L&F to System", e);
        }
    }

    long start = System.currentTimeMillis();

    // Splash
    Splash splash = new Splash("/images/splash.png");
    splash.setVisible(true);

    splash.setCursor(new Cursor(Cursor.WAIT_CURSOR));
    if (System.getSecurityManager() == null) {
        System.setSecurityManager(new RMISecurityManager());
    }

    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
            "org/pegadi/client/client-context.xml");
    closeContextOnShutdown(context);

    long timeToLogin = System.currentTimeMillis() - start;
    log.info("Connected OK after {} ms", timeToLogin);
    log.info("Java Version {}", System.getProperty("java.version"));

    splash.dispose();
}

From source file:Main.java

/**
 * Create a HTML hyperlink in JLabel component
 *
 * @param label//from  ww w .  java2 s .c  o m
 * @param url
 * @param text
 */
public static void createHyperLink(JLabel label, final String url, String text) {
    label.setToolTipText(url);
    label.setText("<html><a href=\"\">" + text + "</a></html>");
    label.setCursor(new Cursor(Cursor.HAND_CURSOR));
    label.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            try {
                Desktop.getDesktop().browse(new URI(url));
            } catch (IOException ex) {
                throw new RuntimeException(ex);
            } catch (URISyntaxException ex) {
                throw new RuntimeException(ex);
            }
        }
    });
}

From source file:Main.java

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

From source file:Main.java

public JHyperlinkLabel(String label) {
    super(label);

    setForeground(Color.BLUE.darker());
    setCursor(new Cursor(Cursor.HAND_CURSOR));
    addMouseListener(new HyperlinkLabelMouseAdapter());
}

From source file:Main.java

public Main() {
    this.setSize(300, 100);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    website.setText("<html> Website:<a href=''>http://www.java2s.com/</a></html>");
    website.setCursor(new Cursor(Cursor.HAND_CURSOR));
    pan.add(website);/*from  w w w  . j  a v a 2s.com*/
    this.setContentPane(pan);
    this.setVisible(true);
    goWebsite(website);
}

From source file:com.mirth.connect.client.ui.components.MirthIconTextField.java

public MirthIconTextField(ImageIcon icon) {
    setIcon(icon);/*from ww  w  .j  a  v a2  s  .  c  om*/

    addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent evt) {
            if (isIconActive(evt) && iconPopupMenuComponent != null) {
                JPopupMenu iconPopupMenu = new JPopupMenu();
                iconPopupMenu.insert(iconPopupMenuComponent, 0);
                iconPopupMenu.show(evt.getComponent(), evt.getX(), evt.getY());
            }
        }
    });

    addMouseMotionListener(new MouseMotionAdapter() {
        @Override
        public void mouseMoved(MouseEvent evt) {
            int cursorType = getCursor().getType();

            if (isIconActive(evt)) {
                if (StringUtils.isNotBlank(alternateToolTipText)) {
                    MirthIconTextField.super.setToolTipText(alternateToolTipText);
                }

                if (iconPopupMenuComponent != null) {
                    if (cursorType != Cursor.HAND_CURSOR) {
                        setCursor(new Cursor(Cursor.HAND_CURSOR));
                    }
                } else {
                    if (cursorType != Cursor.DEFAULT_CURSOR) {
                        setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                    }
                }
            } else {
                if (StringUtils.isNotBlank(alternateToolTipText)) {
                    MirthIconTextField.super.setToolTipText(originalToolTipText);
                }

                if (cursorType != Cursor.TEXT_CURSOR) {
                    setCursor(new Cursor(Cursor.TEXT_CURSOR));
                }
            }
        }
    });
}

From source file:com.ssn.listener.SSNFacebookAlbumSelectionListener.java

@Override
public void valueChanged(TreeSelectionEvent event) {
    DefaultMutableTreeNode node = treeHelper.getTreeNode(event.getPath());

    if (this.form.getHiveTree() != null) {
        this.form.getHiveTree().clearSelection();
    }//from   w w  w.j a  v a2  s. com
    if (this.form.getInstagramTree() != null) {
        this.form.getInstagramTree().clearSelection();
    }

    if (node.isLeaf()) {
        this.form.setCursor(new Cursor(Cursor.WAIT_CURSOR));
        SSNAlbumNode fnode = null;
        try {
            if (((SSNIconData) node.getUserObject()).getObject() instanceof SSNAlbumNode)
                fnode = (SSNAlbumNode) ((SSNIconData) node.getUserObject()).getObject();
        } catch (ClassCastException ee) {
            ee.printStackTrace();
            this.form.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        }
        String facebookDirPath = SSNHelper.getFacebookPhotosDirPath();
        if (fnode != null)
            fileTree.m_display.setText(facebookDirPath + File.separator + fnode);

        SSNIconData iconData = (SSNIconData) node.getUserObject();
        SSNAlbumNode albumNode = (SSNAlbumNode) iconData.getObject();

        MediaOperations mediaOperations = facebook.mediaOperations();

        List<Photo> listPhoto, completePhotoList = new ArrayList<Photo>();
        do {
            PagingParameters pagingParameters = new PagingParameters(100, completePhotoList.size(), null,
                    Calendar.getInstance().getTimeInMillis());
            listPhoto = mediaOperations.getPhotos(albumNode.getAlbum().getId(), pagingParameters);
            completePhotoList.addAll(listPhoto);

        } while (listPhoto.size() > 0);

        createComponents(this.form, completePhotoList, albumNode);
    }

}

From source file:com.mirth.connect.client.ui.LoginPanel.java

private LoginPanel() {
    initComponents();//w  w  w.  ja  v a2  s  .  c o m
    jLabel2.setForeground(UIConstants.HEADER_TITLE_TEXT_COLOR);
    jLabel5.setForeground(UIConstants.HEADER_TITLE_TEXT_COLOR);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setIconImage(new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/mirth_32_ico.png"))
            .getImage());

    mirthCorpImage.setIcon(UIConstants.MIRTHCORP_LOGO);
    mirthCorpImage.setText("");
    mirthCorpImage.setToolTipText(UIConstants.MIRTHCORP_TOOLTIP);
    mirthCorpImage.setCursor(new Cursor(Cursor.HAND_CURSOR));

    mirthCorpImage.addMouseListener(new java.awt.event.MouseAdapter() {

        public void mouseClicked(java.awt.event.MouseEvent evt) {
            BareBonesBrowserLaunch.openURL(UIConstants.MIRTHCORP_URL);
        }
    });

    mirthCorpImage1.setIcon(UIConstants.MIRTHCORP_LOGO);
    mirthCorpImage1.setText("");
    mirthCorpImage1.setToolTipText(UIConstants.MIRTHCORP_TOOLTIP);
    mirthCorpImage1.setCursor(new Cursor(Cursor.HAND_CURSOR));

    mirthCorpImage1.addMouseListener(new java.awt.event.MouseAdapter() {

        public void mouseClicked(java.awt.event.MouseEvent evt) {
            BareBonesBrowserLaunch.openURL(UIConstants.MIRTHCORP_URL);
        }
    });

    placeholderButton.setVisible(false);

    errorTextArea.setBackground(Color.WHITE);
    errorTextArea.setDisabledTextColor(Color.RED);
}