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:edu.harvard.mcz.imagecapture.MainFrame.java

/**
 * @return//from www  .  j  av  a2s  .co  m
 */
private JMenuItem getJMenuItemUsers() {
    if (jMenuItemUsers == null) {
        jMenuItemUsers = new JMenuItem();
        jMenuItemUsers.setText("Users");
        jMenuItemUsers.setMnemonic(KeyEvent.VK_U);
        jMenuItemUsers.setEnabled(false);
        try {
            jMenuItemUsers.setIcon(new ImageIcon(this.getClass()
                    .getResource("/edu/harvard/mcz/imagecapture/resources/people_icon_16px.png")));
        } catch (Exception e) {
            log.error("Can't open icon file for jMenuItemUsers.");
            log.error(e);
        }
        jMenuItemUsers.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent e) {
                Singleton.getSingletonInstance().getMainFrame()
                        .setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                ulb = new UserListBrowser();
                if (slb != null) {
                    jPanelCenter.remove(slb);
                }
                if (ilb != null) {
                    jPanelCenter.remove(ilb);
                }
                jPanelCenter.removeAll();
                jPanelCenter.add(ulb, BorderLayout.CENTER);
                jPanelCenter.revalidate();
                jPanelCenter.repaint();
                Singleton.getSingletonInstance().getMainFrame()
                        .setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        });
    }
    return jMenuItemUsers;
}

From source file:com.signalcollect.sna.visualization.SignalCollectSNATopComponent.java

/**
 * Gets and visualizes the chart of the Degree Distribution
 *
 * @param evt/*w  ww  .ja va2  s . c  o  m*/
 */
private void degreeDistributionButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_degreeDistributionButtonActionPerformed
    try {
        mainPanel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        if (jTextArea1.getText() == null) {
            throw new IllegalArgumentException("No file was chosen!\nPlease choose a valid .gml file");
        }
        if (!jTextArea1.getText().contains(".gml")) {
            throw new IllegalArgumentException(
                    "The chosen file doesn't have the right format!\nPlease choose a valid .gml file");
        }
        distributionFrame.setVisible(false);
        distributionFrame = new JFrame();

        scgc = new DegreeSignalCollectGephiConnectorImpl(fileName);
        JFreeChart chart = scgc.createDegreeDistributionChart(scgc.getDegreeDistribution());
        ChartPanel chartPanel = new ChartPanel(chart);
        Dimension dim = new Dimension(750, 450);
        distributionFrame.setMinimumSize(dim);
        distributionFrame.add(chartPanel);
        chartPanel.setVisible(true);
        chartPanel.validate();

        distributionFrame.pack();
        distributionFrame.setVisible(true);
    } catch (IllegalArgumentException exception) {

        messageFrame = new JFrame();
        JOptionPane.showMessageDialog(messageFrame, exception.getMessage(), "Signal/Collect Error",
                JOptionPane.ERROR_MESSAGE);

    } catch (Exception exception) {
        messageFrame = new JFrame();
        exception.printStackTrace();
        JOptionPane.showMessageDialog(messageFrame,
                "Technical exception happened (" + exception.getCause() + ")", "Signal/Collect Error",
                JOptionPane.ERROR_MESSAGE);
    } finally {
        mainPanel.setCursor(Cursor.getDefaultCursor());
    }
}

From source file:org.openmicroscopy.shoola.agents.treeviewer.browser.BrowserComponent.java

/**
 * Implemented as specified by the {@link Browser} interface.
 * @see Browser#sortTreeNodes(int)/*  w w  w  .  ja v  a 2 s  .co m*/
 */
public void sortTreeNodes(int sortType) {
    switch (model.getState()) {
    //case COUNTING_ITEMS:
    case LOADING_DATA:
    case LOADING_LEAVES:
    case DISCARDED:
        throw new IllegalStateException(
                "This method cannot be invoked in the LOADING_DATA, " + " LOADING_LEAVES or DISCARDED state.");
    }
    switch (sortType) {
    case SORT_NODES_BY_DATE:
    case SORT_NODES_BY_NAME:
        break;
    default:
        throw new IllegalArgumentException("SortType not supported.");
    }
    view.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    view.sortNodes(sortType);
    view.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}

From source file:jhplot.gui.GHPanel.java

/**
 * Print the canvas/*from   ww  w.  j a va 2  s . c  om*/
 * 
 */
public void printGraph() {

    if (isBorderShown())
        showBorders(false);
    CanvasPanel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    Thread t = new Thread() {
        public void run() {
            try {
                PrinterJob prnJob = PrinterJob.getPrinterJob();
                // set the Printable to the PrinterJob
                prnJob.setPrintable(new Printable() {
                    public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) {
                        if (pageIndex == 0) {
                            Graphics2D g2d = (Graphics2D) graphics;
                            double ratioX = pageFormat.getImageableWidth() / CanvasPanel.getSize().width;
                            double ratioY = pageFormat.getImageableHeight() / CanvasPanel.getSize().height;
                            double factor = Math.min(ratioX, ratioY);
                            g2d.scale(factor, factor);
                            g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
                            disableDoubleBuffering(CanvasPanel);
                            CanvasPanel.print(g2d);
                            enableDoubleBuffering(CanvasPanel);
                            return Printable.PAGE_EXISTS;
                        }
                        return Printable.NO_SUCH_PAGE;
                    }
                });

                if (prnJob.printDialog()) {
                    JHPlot.showStatusBarText("Printing..");
                    prnJob.print();
                }
            } catch (PrinterException e) {
                e.printStackTrace();
            }
        }
    };
    t.start();
    CanvasPanel.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}

From source file:com.vgi.mafscaling.OpenLoop.java

protected void loadLogFile() {
    fileChooser.setMultiSelectionEnabled(true);
    if (JFileChooser.APPROVE_OPTION != fileChooser.showOpenDialog(this))
        return;//from   w  ww .  jav  a2 s  .c  om
    boolean isPolSet = polfTable.isSet();
    File[] files = fileChooser.getSelectedFiles();
    for (File file : files) {
        BufferedReader br = null;
        ArrayDeque<String[]> buffer = new ArrayDeque<String[]>();
        try {
            br = new BufferedReader(new FileReader(file.getAbsoluteFile()));
            String line = br.readLine();
            if (line != null) {
                String[] elements = line.split("(\\s*)?,(\\s*)?", -1);
                getColumnsFilters(elements, false);

                boolean resetColumns = false;
                if (logThtlAngleColIdx >= 0 || logAfLearningColIdx >= 0 || logAfCorrectionColIdx >= 0
                        || logMafvColIdx >= 0 || logAfrColIdx >= 0 || logRpmColIdx >= 0 || logLoadColIdx >= 0
                        || logCommandedAfrCol >= 0) {
                    if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(null,
                            "Would you like to reset column names or filter values?", "Columns/Filters Reset",
                            JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE))
                        resetColumns = true;
                }

                if (resetColumns || logThtlAngleColIdx < 0 || logAfLearningColIdx < 0
                        || logAfCorrectionColIdx < 0 || logMafvColIdx < 0 || logAfrColIdx < 0
                        || logRpmColIdx < 0 || logLoadColIdx < 0 || (logCommandedAfrCol < 0 && !isPolSet)) {
                    ColumnsFiltersSelection selectionWindow = new OLColumnsFiltersSelection(isPolSet);
                    if (!selectionWindow.getUserSettings(elements) || !getColumnsFilters(elements, isPolSet))
                        return;
                }

                String[] flds;
                String[] afrflds;
                boolean wotFlag = true;
                boolean foundWot = false;
                double throttle;
                double stft;
                double ltft;
                double afr;
                double rpm;
                double load;
                double mafv;
                double cmdafr = 0;
                double afrErr = 0;
                int skipRowCount = 0;
                int row = 0;
                int i = 0;
                int j = 0;
                for (; i < runTables.length; ++i) {
                    if (runTables[i].getValueAt(0, 0).toString().isEmpty())
                        break;
                }
                if (i == runTables.length)
                    return;
                setCursor(new Cursor(Cursor.WAIT_CURSOR));
                for (int k = 0; k <= afrRowOffset && line != null; ++k) {
                    line = br.readLine();
                    if (line != null)
                        buffer.addFirst(line.split(",", -1));
                }
                while (line != null && buffer.size() > afrRowOffset) {
                    afrflds = buffer.getFirst();
                    flds = buffer.removeLast();
                    line = br.readLine();
                    if (line != null)
                        buffer.addFirst(line.split(",", -1));

                    try {
                        throttle = Double.valueOf(flds[logThtlAngleColIdx]);
                        if (row == 0 && throttle < 99)
                            wotFlag = false;
                        if (throttle < wotPoint) {
                            if (wotFlag == true) {
                                wotFlag = false;
                                skipRowCount = 0;
                                j -= 1;
                                while (j > 0 && skipRowCount < skipRowsOnTransition) {
                                    runTables[i].setValueAt("", j, 0);
                                    runTables[i].setValueAt("", j, 1);
                                    runTables[i].setValueAt("", j, 2);
                                    skipRowCount += 1;
                                    j -= 1;
                                }
                                skipRowCount = 0;
                            }
                        } else {
                            if (wotFlag == false) {
                                wotFlag = true;
                                skipRowCount = 0;
                                if (foundWot) {
                                    i += 1;
                                    if (i == runTables.length)
                                        return;
                                }
                                if (row > 0)
                                    j = 0;
                            }
                            if (skipRowCount >= skipRowsOnTransition) {
                                mafv = Double.valueOf(flds[logMafvColIdx]);
                                if (minMafV <= mafv) {
                                    foundWot = true;
                                    stft = Double.valueOf(flds[logAfCorrectionColIdx]);
                                    ltft = Double.valueOf(flds[logAfLearningColIdx]);
                                    afr = Double.valueOf(afrflds[logAfrColIdx]);
                                    rpm = Double.valueOf(flds[logRpmColIdx]);
                                    load = Double.valueOf(flds[logLoadColIdx]);

                                    afr = afr / ((100.0 - (ltft + stft)) / 100.0);

                                    if (logCommandedAfrCol >= 0)
                                        cmdafr = Double.valueOf(flds[logCommandedAfrCol]);
                                    else if (isPolSet)
                                        cmdafr = Utils.calculateCommandedAfr(rpm, load, minWotEnrichment,
                                                polfTable);
                                    else {
                                        JOptionPane.showMessageDialog(null,
                                                "Please set either \"Commanded AFR\" column or \"Primary Open Loop Fueling\" table",
                                                "Error", JOptionPane.ERROR_MESSAGE);
                                        return;
                                    }

                                    afrErr = (afr - cmdafr) / cmdafr * 100.0;
                                    if (Math.abs(afrErr) <= afrErrPrct) {
                                        Utils.ensureRowCount(j + 1, runTables[i]);
                                        runTables[i].setValueAt(rpm, j, 0);
                                        runTables[i].setValueAt(mafv, j, 1);
                                        runTables[i].setValueAt(afrErr, j, 2);
                                        j += 1;
                                    }
                                }
                            }
                            skipRowCount += 1;
                        }
                    } catch (NumberFormatException e) {
                        logger.error(e);
                        JOptionPane.showMessageDialog(null,
                                "Error parsing number at " + file.getName() + " line " + (row + 1) + ": " + e,
                                "Error processing file", JOptionPane.ERROR_MESSAGE);
                        return;
                    }
                    row += 1;
                }

                if (!foundWot) {
                    setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                    JOptionPane.showMessageDialog(null, "Sorry, no WOT pulls were found in the log file",
                            "No WOT data", JOptionPane.INFORMATION_MESSAGE);
                }
            }
        } catch (Exception e) {
            logger.error(e);
            JOptionPane.showMessageDialog(null, e, "Error opening file", JOptionPane.ERROR_MESSAGE);
        } finally {
            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
            if (br != null) {
                try {
                    br.close();
                } catch (IOException e) {
                    logger.error(e);
                }
            }
        }
    }
}

From source file:cish.CISH.java

/**
 * Performs the CISH analysis on currently selected TMAspots.
 *///from   w  w  w  .j a v a2  s  . co  m
void doCISH() {
    this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    this.tss = manager.getSelectedTMAspots();
    this.gRatios = new double[tss.size()];
    this.lRatios = new double[tss.size()];
    this.ps = new int[tss.size()][][];

    if (!tss.isEmpty()) {
        if (thread != null) {
            if (thread.isAlive()) {
                thread.interrupt();
            }
        }
        thread = new CISH_Thread((TMARKERPluginManager) manager, this, this.tss, getParam_PointSignalRadius(),
                getParam_nPts(), getParam_darkpoints(), gRatios, lRatios, ps, classifier, dataset);
        thread.start();
    }

    this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}

From source file:com.github.fritaly.dualcommander.DualCommander.java

public void setWaitCursor() {
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
}

From source file:au.com.jwatmuff.eventmanager.gui.main.MainWindow.java

private void firewallMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_firewallMenuItemActionPerformed
    String rule = "EventManager Port 1199";
    String title = "Update Firewall";

    try {//from   ww  w .jav a2 s .c  om
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        if (WindowsNetUtil.firewallRuleExists(rule)) {
            GUIUtils.displayMessage(null, "Firewall already configured", title);
            return;
        }
        WindowsNetUtil.openInboundFirewallPort(rule, 1199);
    } finally {
        setCursor(Cursor.getDefaultCursor());
    }
    if (WindowsNetUtil.firewallRuleExists(rule)) {
        GUIUtils.displayMessage(null, "Firewall Successfully Updated", title);
    } else {
        GUIUtils.displayError(null, "Failed to update firewall");
    }
}

From source file:au.com.jwatmuff.eventmanager.gui.main.MainWindow.java

private void networkLogMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_networkLogMenuItemActionPerformed
    try {//  www .j  a  v a2 s  . c  o  m
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        WindowsNetUtil.logNetworkInfo();
    } finally {
        setCursor(Cursor.getDefaultCursor());
    }

    GUIUtils.displayMessage(null,
            "Network diagnostic information has been logged.\nThis will assist the developers to resolve network related issues with EventManager.",
            "Log Network Info");
}

From source file:com.josescalia.tumblr.form.TumblrImageViewer.java

private void btnDownloadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDownloadActionPerformed
    frame = (MainFrame) this.getTopLevelAncestor();
    form = this;/*w w  w . jav  a2s  .  c  om*/
    /*since the application using cache, all we need is only copying target file to destination folder*/

    //busy cursor and progress bar panel and frame
    form.setCursor(new Cursor(Cursor.WAIT_CURSOR));
    frame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
    frame.startProgressBar("Downloading");
    new SwingWorker<String, String>() {
        @Override
        protected String doInBackground() throws Exception {
            int successCount = 0;
            int failedCount = 0;
            for (DownloadableImage image : imgList) {
                String fileName = image.getUrl().substring(image.getUrl().lastIndexOf("/") + 1);
                String downloadUrl = image.getUrl();
                File targetFile = new File(BinaryCacheUtil.getBinaryImagePath(".cache", fileName, downloadUrl));
                try {
                    FileSystemUtils.copyRecursively(targetFile, new File(downloadPath + "//" + fileName));
                    successCount++;
                } catch (IOException e) {
                    logger.error("Copy Failed Exception : " + e.getMessage());
                    failedCount++;
                }
            }
            return "Download file finished : \n" + successCount + " file(s) downloaded successfully \n"
                    + failedCount + "failed to download";
        }

        @Override
        protected void done() {
            try {
                UIAlert.showInformation(null, get());
            } catch (InterruptedException e) {
                logger.error(e);
            } catch (ExecutionException e) {
                logger.error(e);
            }
            form.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
            frame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
            frame.stopProgressBar("");
        }
    }.execute();

}