Example usage for java.awt Cursor WAIT_CURSOR

List of usage examples for java.awt Cursor WAIT_CURSOR

Introduction

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

Prototype

int WAIT_CURSOR

To view the source code for java.awt Cursor WAIT_CURSOR.

Click Source Link

Document

The wait cursor type.

Usage

From source file:us.paulevans.basicxslt.OutputFrame.java

/**
 * Event handler method.//from  w w  w  . j  a  v  a2s.c  o m
 * 
 * @param aEvt
 */
public void actionPerformed(ActionEvent aEvt) {

    int returnVal;
    File fileToSave;

    setCursor(new Cursor(Cursor.WAIT_CURSOR));
    if (aEvt.getSource() == closeBtn || aEvt.getSource() == close) {
        dispose(userPrefs, PROPERTY_NAME_PREFIX);
    } else if (aEvt.getSource() == transformTimings) {
        new TimingsFrame(this, xslRows);
    } else if (aEvt.getSource() == saveOutputBtn) {
        try {
            returnVal = Utils.getInstance().getFileChooser().showSaveDialog(this);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                fileToSave = Utils.getInstance().getFileChooser().getSelectedFile();
                BasicXSLTFrame.setLastFileChosen(fileToSave.getAbsolutePath());
                if (textArea != null) {
                    IOUtils.writeFile(fileToSave, transformResult);
                } else {
                    IOUtils.writeFile(fileToSave, XMLUtils.serialize(node, lastTransformOutputProps));
                }
            }
        } catch (Throwable aAny) {
            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
            logger.error(ExceptionUtils.getFullStackTrace(aAny));
            Utils.showErrorDialog(this, aAny);
        }
    }
}

From source file:net.vanosten.dings.swing.SummaryView.java

/**
 * Shows the chosen grahp in the display area.
 *//* w ww  .  j a  va2 s.c  o  m*/
private void showChart() {
    this.setCursor(new Cursor(Cursor.WAIT_CURSOR)); //will be set back in placeChart()
    AppEvent evt = new AppEvent(AppEvent.EventType.DATA_EVENT);
    switch (chartTypeCB.getSelectedIndex()) {
    case 0:
        evt.setMessage(MessageConstants.Message.D_SUMMARY_VIEW_DISPLAY_UNITS);
        break;
    case 1:
        evt.setMessage(MessageConstants.Message.D_SUMMARY_VIEW_DISPLAY_CATEGORIES);
        break;
    case 2:
        evt.setMessage(MessageConstants.Message.D_SUMMARY_VIEW_DISPLAY_ENTRYTYPES);
        break;
    case 3:
        evt.setMessage(MessageConstants.Message.D_SUMMARY_VIEW_DISPLAY_SCORES);
        break;
    default:
        evt.setMessage(MessageConstants.Message.D_SUMMARY_VIEW_DISPLAY_TIMELINE);
        break;
    }
    evt.setDetails(Boolean.toString(chosenCB.isSelected()));
    controller.handleAppEvent(evt);
}

From source file:net.sf.mzmine.modules.peaklistmethods.peakpicking.adap3decompositionV2.ADAP3DecompositionV2SetupDialog.java

@Override
public void actionPerformed(ActionEvent e) {
    super.actionPerformed(e);

    final Object source = e.getSource();

    if (source.equals(chkPreview)) {
        if (chkPreview.isSelected()) {
            // Set the height of the chkPreview to 200 cells, so it will span
            // the whole vertical length of the dialog (buttons are at row
            // no 100). Also, we set the weight to 10, so the chkPreview
            // component will consume most of the extra available space.
            mainPanel.add(pnlPlots, 3, 0, 1, 200, 10, 10, GridBagConstraints.BOTH);
            pnlUIElements.add(pnlComboBoxes, BorderLayout.CENTER);
            //                cboPeakLists.setSelectedIndex(0);
        } else {/*w  w  w  .ja  v a 2  s. c o m*/
            mainPanel.remove(pnlPlots);
            pnlUIElements.remove(pnlComboBoxes);
        }

        updateMinimumSize();
        pack();
        setLocationRelativeTo(MZmineCore.getDesktop().getMainWindow());

        retTimeCluster();
    }

    else if (source.equals(cboClusters)) {
        Cursor cursor = this.getCursor();
        this.setCursor(new Cursor(Cursor.WAIT_CURSOR));

        shapeCluster();

        this.setCursor(cursor);
    }
}

From source file:it.imtech.metadata.MetaUtility.java

private JComboBox addClassificationChoice(JPanel choice, final String sequence, final String panelname) {

    int selected = 0;
    int index = 0;
    int count = 1;

    for (Map.Entry<String, String> vc : availableClassifications.entrySet()) {
        if (count == 1 && !selectedClassificationList.containsKey(panelname + "---" + sequence)) {
            selected = index;//from   w  w  w.jav a 2  s. co m
            selectedClassificationList.put(panelname + "---" + sequence, vc.getKey());
        }

        if (selectedClassificationList.containsKey(panelname + "---" + sequence)) {
            if (selectedClassificationList.get(panelname + "---" + sequence).equals(vc.getKey())) {
                selected = index;
            }
        }
        index++;
    }
    try {
        classifications_reader(sequence, panelname);
    } catch (Exception ex) {
        logger.error(ex.getMessage());
    }

    final ComboMapImpl model = new ComboMapImpl();
    model.putAllLinked(availableClassifications);

    JComboBox result = new javax.swing.JComboBox(model);

    result.setSelectedIndex(selected);
    model.specialRenderCombo(result);

    result.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            BookImporter.getInstance().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

            JComboBox comboBox = (JComboBox) event.getSource();
            Map.Entry<String, String> c = (Map.Entry<String, String>) comboBox.getSelectedItem();

            selectedClassificationList.put(panelname + "---" + sequence, c.getKey());

            BookImporter.getInstance()
                    .createComponentMap(BookImporter.getInstance().metadatapanels.get(panelname).getPanel());
            JPanel innerPanel = (JPanel) BookImporter.getInstance()
                    .getComponentByName(panelname + "---ImPannelloClassif---" + sequence);
            innerPanel.removeAll();

            try {
                classifications_reader(sequence, panelname);
                addClassification(innerPanel, classificationMID, sequence, panelname);
            } catch (Exception ex) {
                logger.error(ex.getMessage());
            }

            innerPanel.revalidate();
            BookImporter.getInstance().setCursor(null);
        }
    });

    return result;
}

From source file:org.adempiere.apps.graph.Graph.java

public void chartMouseClicked(ChartMouseEvent event) {
    if ((event.getEntity() != null) && (event.getTrigger().getClickCount() > 1)) {
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        try {/*from ww  w .j ava2s .c o m*/
            GraphColumn bgc = getGraphColumn(event);
            if (bgc == null) {
                return;
            }

            MQuery query = bgc.getMQuery(builder.getMGoal());
            if (query != null)
                AEnv.zoom(query);
            else
                log.warning("Nothing to zoom to - " + bgc);
        } finally {
            setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
        }
    }
}

From source file:com.mirth.connect.manager.ManagerController.java

public void stopMirthWorker() {
    PlatformUI.MANAGER_DIALOG.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    setEnabledOptions(false, false, false, false);

    SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {
        private String errorMessage = null;

        public Void doInBackground() {
            errorMessage = stopMirth();//from   w  w  w.jav  a  2  s .c  o  m
            return null;
        }

        public void done() {
            if (errorMessage == null) {
                PlatformUI.MANAGER_TRAY.alertInfo("The Mirth Connect Service was stopped successfully.");
            } else {
                PlatformUI.MANAGER_TRAY.alertError(errorMessage);
            }

            updateMirthServiceStatus();
            PlatformUI.MANAGER_DIALOG.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
        }
    };

    worker.execute();
}

From source file:org.martus.client.swingui.FxInSwingMainWindow.java

@Override
public Object getWaitCursor() {
    return Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
}

From source file:net.sf.vfsjfilechooser.accessories.connection.ConnectionDialog.java

private void initListeners() {
    this.portTextField.addKeyListener(new KeyAdapter() {
        @Override/*from  ww w.ja  v a2s  . c om*/
        public void keyTyped(KeyEvent e) {
            char c = e.getKeyChar();

            if (!((Character.isDigit(c) || (c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)))) {
                getToolkit().beep();
                e.consume();
            } else {
                setPortTextFieldDirty(true);
            }
        }
    });

    this.portTextField.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
            JFormattedTextField f = (JFormattedTextField) e.getSource();
            String text = f.getText();

            if (text.length() == 0) {
                f.setValue(null);
            }

            try {
                f.commitEdit();
            } catch (ParseException exc) {
            }
        }
    });

    this.cancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (currentWorker != null) {
                if (currentWorker.isAlive()) {
                    currentWorker.interrupt();
                    setCursor(Cursor.getDefaultCursor());
                }
            }

            setVisible(false);
        }
    });

    this.connectButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            currentWorker = new Thread() {
                @Override
                public void run() {
                    StringBuilder error = new StringBuilder();
                    FileObject fo = null;

                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

                    try {
                        String m_username = usernameTextField.getText();
                        String m_defaultRemotePath = defaultRemotePathTextField.getText();
                        char[] m_password = passwordTextField.getPassword();
                        String m_hostname = hostnameTextField.getText();
                        String m_protocol = protocolList.getSelectedItem().toString();

                        int m_port = -1;

                        if (portTextField.isEditValid() && (portTextField.getValue() != null)) {
                            String s = portTextField.getValue().toString();
                            m_port = Integer.valueOf(s);
                        }

                        Builder credentialsBuilder = Credentials.newBuilder(m_hostname)
                                .defaultRemotePath(m_defaultRemotePath).username(m_username)
                                .password(m_password).protocol(m_protocol).port(m_port);

                        Credentials credentials = credentialsBuilder.build();

                        String uri = credentials.toFileObjectURL();

                        if (isInterrupted()) {
                            setPortTextFieldDirty(false);

                            return;
                        }

                        fo = VFSUtils.resolveFileObject(uri);

                        if ((fo != null) && !fo.exists()) {
                            fo = null;
                        }
                    } catch (Exception err) {
                        error.append(err.getMessage());
                        setCursor(Cursor.getDefaultCursor());
                    }

                    if ((error.length() > 0) || (fo == null)) {
                        error.delete(0, error.length());
                        error.append("Failed to connect!");
                        error.append("\n");
                        error.append("Please check parameters and try again.");

                        JOptionPane.showMessageDialog(ConnectionDialog.this, error, "Error",
                                JOptionPane.ERROR_MESSAGE);
                        setCursor(Cursor.getDefaultCursor());

                        return;
                    }

                    if (isInterrupted()) {
                        return;
                    }

                    fileChooser.setCurrentDirectory(fo);

                    setCursor(Cursor.getDefaultCursor());

                    resetFields();

                    if (bookmarksDialog != null) {
                        String bTitle = fo.getName().getBaseName();

                        if (bTitle.trim().equals("")) {
                            bTitle = fo.getName().toString();
                        }

                        String bURL = fo.getName().getURI();
                        bookmarksDialog.getBookmarks().add(new TitledURLEntry(bTitle, bURL));
                        bookmarksDialog.getBookmarks().save();
                    }

                    setVisible(false);
                }
            };

            currentWorker.setPriority(Thread.MIN_PRIORITY);
            currentWorker.start();
        }
    });

    // add the usual right click popup menu(copy, paste, etc.)
    PopupHandler.installDefaultMouseListener(hostnameTextField);
    PopupHandler.installDefaultMouseListener(portTextField);
    PopupHandler.installDefaultMouseListener(usernameTextField);
    PopupHandler.installDefaultMouseListener(passwordTextField);
    PopupHandler.installDefaultMouseListener(defaultRemotePathTextField);

    this.protocolList.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                selectPortNumber();
            }
        }
    });

    this.protocolList.setSelectedItem(Protocol.FTP);
}

From source file:com.googlecode.vfsjfilechooser2.accessories.connection.ConnectionDialog.java

private void initListeners() {
    this.portTextField.addKeyListener(new KeyAdapter() {
        @Override//w  w w. jav  a  2s.co m
        public void keyTyped(KeyEvent e) {
            char c = e.getKeyChar();

            if (!((Character.isDigit(c) || (c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)))) {
                getToolkit().beep();
                e.consume();
            } else {
                setPortTextFieldDirty(true);
            }
        }
    });

    this.portTextField.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
            JFormattedTextField f = (JFormattedTextField) e.getSource();
            String text = f.getText();

            if (text.length() == 0) {
                f.setValue(null);
            }

            try {
                f.commitEdit();
            } catch (ParseException exc) {
            }
        }
    });

    this.cancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (currentWorker != null) {
                if (currentWorker.isAlive()) {
                    currentWorker.interrupt();
                    setCursor(Cursor.getDefaultCursor());
                }
            }

            setVisible(false);
        }
    });

    this.connectButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            currentWorker = new Thread() {
                @Override
                public void run() {
                    StringBuilder error = new StringBuilder();
                    FileObject fo = null;

                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

                    try {
                        String m_username = usernameTextField.getText();
                        String m_defaultRemotePath = defaultRemotePathTextField.getText();
                        char[] m_password = passwordTextField.getPassword();
                        String m_hostname = hostnameTextField.getText();
                        String m_protocol = protocolList.getSelectedItem().toString();

                        int m_port = -1;

                        if (portTextField.isEditValid() && (portTextField.getValue() != null)) {
                            String s = portTextField.getValue().toString();
                            m_port = Integer.valueOf(s);
                        }

                        Builder credentialsBuilder = Credentials.newBuilder(m_hostname)
                                .defaultRemotePath(m_defaultRemotePath).username(m_username)
                                .password(m_password).protocol(m_protocol).port(m_port);

                        Credentials credentials = credentialsBuilder.build();

                        String uri = credentials.toFileObjectURL();

                        if (isInterrupted()) {
                            setPortTextFieldDirty(false);

                            return;
                        }

                        fo = VFSUtils.resolveFileObject(uri);

                        if ((fo != null) && !fo.exists()) {
                            fo = null;
                        }
                    } catch (Exception err) {
                        error.append(err.getMessage());
                        setCursor(Cursor.getDefaultCursor());
                    }

                    if ((error.length() > 0) || (fo == null)) {
                        error.delete(0, error.length());
                        error.append("Failed to connect!");
                        error.append("\n");
                        error.append("Please check parameters and try again.");

                        JOptionPane.showMessageDialog(ConnectionDialog.this, error, "Error",
                                JOptionPane.ERROR_MESSAGE);
                        setCursor(Cursor.getDefaultCursor());

                        return;
                    }

                    if (isInterrupted()) {
                        return;
                    }

                    fileChooser.setCurrentDirectoryObject(fo);

                    setCursor(Cursor.getDefaultCursor());

                    resetFields();

                    if (bookmarksDialog != null) {
                        String bTitle = fo.getName().getBaseName();

                        if (bTitle.trim().equals("")) {
                            bTitle = fo.getName().toString();
                        }

                        String bURL = fo.getName().getURI();
                        bookmarksDialog.getBookmarks().add(new TitledURLEntry(bTitle, bURL));
                        bookmarksDialog.getBookmarks().save();
                    }

                    setVisible(false);
                }
            };

            currentWorker.setPriority(Thread.MIN_PRIORITY);
            currentWorker.start();
        }
    });

    // add the usual right click popup menu(copy, paste, etc.)
    PopupHandler.installDefaultMouseListener(hostnameTextField);
    PopupHandler.installDefaultMouseListener(portTextField);
    PopupHandler.installDefaultMouseListener(usernameTextField);
    PopupHandler.installDefaultMouseListener(passwordTextField);
    PopupHandler.installDefaultMouseListener(defaultRemotePathTextField);

    this.protocolList.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                selectPortNumber();
            }
        }
    });

    this.protocolList.setSelectedItem(Protocol.FTP);
}