Example usage for java.awt Cursor getPredefinedCursor

List of usage examples for java.awt Cursor getPredefinedCursor

Introduction

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

Prototype

public static Cursor getPredefinedCursor(int type) 

Source Link

Document

Returns a cursor object with the specified predefined type.

Usage

From source file:edu.harvard.mcz.imagecapture.ImageCaptureApp.java

/**Main method for starting the application.
 * //from   www.  j ava  2 s .  c  o m
 * @param args are not used.
 */
public static void main(String[] args) {

    log.debug(UIManager.getLookAndFeel());
    log.debug(UIManager.getLookAndFeel().getID());

    if (UIManager.getLookAndFeel().getID().equals("Aqua")) {
        // check for "Aqua"
        try {
            UIManager.setLookAndFeel(
                    // OSX Aqua look and feel uses space on forms much too inefficiently
                    // switch to the normal Java look and feel instead.
                    UIManager.getCrossPlatformLookAndFeelClassName());
        } catch (UnsupportedLookAndFeelException e) {
            log.error(e);
        } catch (ClassNotFoundException e) {
            log.error(e);
        } catch (InstantiationException e) {
            log.error(e);
        } catch (IllegalAccessException e) {
            log.error(e);
        }
    }

    System.out.println("Starting " + APP_NAME + " " + APP_VERSION);
    System.out.println(APP_COPYRIGHT);
    System.out.println(APP_LICENSE);
    log.debug("Starting " + APP_NAME + " " + APP_VERSION);

    // open UI and start
    MainFrame mainFrame = new MainFrame();
    Singleton.getSingletonInstance().setMainFrame(mainFrame);
    Singleton.getSingletonInstance().getMainFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    Singleton.getSingletonInstance().unsetCurrentUser();
    Singleton.getSingletonInstance().getMainFrame().setStatusMessage("Starting....");
    log.debug("User interface started");

    // Load properties
    ImageCaptureProperties properties = new ImageCaptureProperties();
    Singleton.getSingletonInstance().setProperties(properties);
    log.debug("Properties loaded");

    // Set up a barcode (text read from barcode label for pin) matcher/builder
    if (Singleton.getSingletonInstance().getProperties().getProperties()
            .getProperty(ImageCaptureProperties.KEY_COLLECTION)
            .equals(ImageCaptureProperties.COLLECTION_MCZENT)) {
        // ** Configured for the MCZ Entomology Collection, use MCZ assumptions.
        MCZENTBarcode barcodeTextBuilderMatcher = new MCZENTBarcode();
        Singleton.getSingletonInstance().setBarcodeBuilder((BarcodeBuilder) barcodeTextBuilderMatcher);
        Singleton.getSingletonInstance().setBarcodeMatcher((BarcodeMatcher) barcodeTextBuilderMatcher);
    } else if (Singleton.getSingletonInstance().getProperties().getProperties()
            .getProperty(ImageCaptureProperties.KEY_COLLECTION)
            .equals(ImageCaptureProperties.COLLECTION_ETHZENT)) {
        // ** Configured for the ETHZ Entomology Collection, use MCZ assumptions.
        ETHZBarcode barcodeTextBuilderMatcher = new ETHZBarcode();
        Singleton.getSingletonInstance().setBarcodeBuilder((BarcodeBuilder) barcodeTextBuilderMatcher);
        Singleton.getSingletonInstance().setBarcodeMatcher((BarcodeMatcher) barcodeTextBuilderMatcher);
    } else {
        log.error("Configured collection not recognized.  Unable to Start");
        ImageCaptureApp.exit(EXIT_ERROR);
    }

    // Force a login dialog by connecting to obtain record count;
    SpecimenLifeCycle sls = new SpecimenLifeCycle();
    try {
        Singleton.getSingletonInstance().getMainFrame().setCount(sls.findSpecimenCountThrows());
        ImageCaptureApp.doStartUp();
    } catch (ConnectionException e) {
        log.error(e.getMessage());
        ImageCaptureApp.doStartUpNot();
    }

    // Experimental chat support, working on localhost.

    /** 
            
       Context context = null;
       Hashtable contextProperties = new Hashtable(2);
            
       contextProperties.put(Context.PROVIDER_URL,"iiop://127.0.0.1:3700");
       contextProperties.put("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
       contextProperties.put("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
       contextProperties.put("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
       try {
    context = new InitialContext(contextProperties);
       } catch (NamingException ex) {
    ex.printStackTrace();
       }
       if (context!=null) { 
    ConnectionFactory connectionFactory;
    try {
       connectionFactory = (ConnectionFactory)context.lookup("jms/InsectChatTopicFactory");
       Topic chatTopic = (Topic)context.lookup("jms/InsectChatTopic");
       TopicConnection connection = (TopicConnection) connectionFactory.createConnection();
       TopicSession session = connection.createTopicSession(false,Session.AUTO_ACKNOWLEDGE);
       TopicSubscriber subscriber = session.createSubscriber(chatTopic);
       connection.start();
       while (true) {
          Message m = subscriber.receive(1);
          if (m != null) {
             if (m instanceof TextMessage) {
                TextMessage message = (TextMessage) m;
                String originator = message.getStringProperty("Originator");
                String text = message.getText();
                System.out.println("Message: " + originator + ": " + text);
             } else {
                break;
             }
          }
       }
    } catch (NamingException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
    } catch (JMSException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
    }
       }
    } 
      */

}

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 setBusyCursor(Component comp, boolean busy) {
    if (busy) {//  www .ja v a  2s  .  c  o m
        comp.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    } else {
        comp.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    }
}

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);//  ww  w .j av  a2  s. com
    frame.setSize(300, 300);
    frame.setVisible(true);
}

From source file:Main.java

public static Cursor getHandCursor() {
    if (mHandCursor == null) {
        mHandCursor = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR);
    }//from  w w  w  .  j  a v a  2s.c om

    return mHandCursor;
}

From source file:Main.java

/**
 * Configures a label as if it was an hyperlink.
 * /*w ww.jav a2s . c  o  m*/
 * @param label
 *            the label to configure.
 */
public static void configureLabelAsHyperlink(JLabel label) {
    if (label == null) {
        return;
    }

    StringBuffer html = new StringBuffer();
    html.append("<html><font color=\"blue\"><u>");
    html.append(label.getText());
    html.append("</u></font></html>");

    label.setText(html.toString());
    label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}

From source file:Main.java

/**
 * Configures a button as if it was an hyperlink.
 * // w ww.  ja v a 2s .  co m
 * @param button
 *            the button to configure.
 */
public static void configureButtonAsHyperlink(JButton button) {
    if (button == null) {
        return;
    }

    StringBuffer html = new StringBuffer();
    html.append("<html><font color=\"blue\"><u>");
    html.append(button.getText());
    html.append("</u></font></html>");

    button.setText(html.toString());
    button.setMargin(new Insets(0, 0, 0, 0));
    button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    button.setFocusPainted(false);
    button.setBorderPainted(false);
    button.setContentAreaFilled(false);
}

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.
 *//*from   w w w  .j a  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);
        }
    });
}

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.
 *//*from  www . j  a  v  a  2 s.co  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);
        }
    });
}

From source file:Main.java

private void ShowDialog() {
    JLabel label = new JLabel("Move mouse here for hand cursor");
    label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    JOptionPane pane = new JOptionPane(label);
    pane.setOptions(new Object[] { "OK" });

    JDialog dialog = pane.createDialog(this, "Test Dialog");
    dialog.setVisible(true);/*ww w  .  j ava2  s .  co  m*/
}