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:neg.JRViewerDet2.java

void btnPrintActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnPrintActionPerformed
{//GEN-HEADEREND:event_btnPrintActionPerformed
 // Add your handling code here:

    Thread thread = new Thread(new Runnable() {
        public void run() {
            try {

                btnPrint.setEnabled(false);
                JRViewerDet2.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                JasperPrintManager.printReport(jasperPrint, true);
            } catch (Exception ex) {
                if (log.isErrorEnabled())
                    log.error("Print error.", ex);

                JOptionPane.showMessageDialog(JRViewerDet2.this, getBundleString("error.printing"));
            } finally {
                JRViewerDet2.this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                btnPrint.setEnabled(true);
            }//from  w  w  w.j a v  a  2 s.  co  m
        }
    });

    thread.start();

}

From source file:ded.ui.DiagramController.java

/** Write the diagram in PNG format to 'file' with an optional comment.
  * The comment must only use ASCII characters. */
public void writeToPNG(File file, String comment) throws Exception {
    // For a large-ish diagram, this operation takes ~200ms.  For now,
    // I will just acknowledge the delay.  An idea for the future is
    // to add a status bar to the UI, then do the export work in a
    // separate thread, with an indicator in the status bar that will
    // reflect when the operation completes.  I consider it important
    // for the user to know when it finishes so if it takes a long
    // time, they don't in the meantime go copy or view the partially
    // written image.
    this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    try {/*from ww w .  j a v a 2  s .c  o m*/
        // Based on code from:
        // http://stackoverflow.com/questions/5655908/export-jpanel-graphics-to-png-or-gif-or-jpg

        // First, render the image to an in-memory image buffer.
        BufferedImage bi = new BufferedImage(this.getSize().width, this.getSize().height,
                BufferedImage.TYPE_INT_ARGB);
        Graphics g = bi.createGraphics();
        this.paintWithoutSelectionsShowing(g);
        g.dispose();

        // Now, write that image to a file in PNG format.
        String warning = ImageFileUtil.writeImageToPNGFile(bi, file, comment);
        if (warning != null) {
            SwingUtil.warningMessageBox(this, "File save completed successfully, but while exporting to PNG, "
                    + "there was a warning: " + warning);
        }
    } finally {
        this.setCursor(Cursor.getDefaultCursor());
    }
}

From source file:cn.pholance.datamanager.common.components.JRViewer.java

void btnPrintActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnPrintActionPerformed
{//GEN-HEADEREND:event_btnPrintActionPerformed
 // Add your handling code here:

    Thread thread = new Thread(new Runnable() {
        public void run() {
            try {

                btnPrint.setEnabled(false);
                JRViewer.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                JasperPrintManager.getInstance(jasperReportsContext).print(jasperPrint, true);
            } catch (Exception ex) {
                if (log.isErrorEnabled()) {
                    log.error("Print error.", ex);
                }//from  w ww.ja va2s  . c  o m
                JOptionPane.showMessageDialog(JRViewer.this, getBundleString("error.printing"));
            } finally {
                JRViewer.this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                btnPrint.setEnabled(true);
            }
        }
    });

    thread.start();

}

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

private void loadLogFile() {
    fileChooser.setMultiSelectionEnabled(false);
    if (JFileChooser.APPROVE_OPTION != fileChooser.showOpenDialog(this))
        return;/*from   w ww .  j ava  2s. co  m*/
    // close log player
    if (logPlayWindow != null)
        disposeLogView();
    // process log file
    File file = fileChooser.getSelectedFile();
    Properties prop = new Properties();
    prop.put("delimiter", ",");
    prop.put("firstRowHasColumnNames", "true");
    setCursor(new Cursor(Cursor.WAIT_CURSOR));
    logDataTable.filter(null);
    filterText.setText("");
    try {
        for (int i = 0; i < logDataTable.getColumnCount(); ++i)
            logDataTable.getTableHeader().removeMouseListener(
                    ((CheckboxHeaderRenderer) logDataTable.getColumn(i).getHeaderRenderer())
                            .getMouseListener());
        logDataTable.refresh(file.toURI().toURL(), prop);
        Column col;
        String colName;
        String lcColName;
        String val;
        CheckboxHeaderRenderer renderer;
        Component comp;
        XYSeries series;
        xAxisColumn.removeAllItems();
        yAxisColumn.removeAllItems();
        plotsColumn.removeAllItems();
        xAxisColumn.addItem("");
        yAxisColumn.addItem("");
        plotsColumn.setText("");
        plot3d.removeAllPlots();
        rpmDataset.removeAllSeries();
        dataset.removeAllSeries();
        xyMarker.clearLabels(true);
        rpmCol = -1;
        displCount = 0;
        selectionCombo.removeAllItems();
        listModel.removeAllElements();
        JTableHeader tableHeader = logDataTable.getTableHeader();
        for (int i = 0; i < logDataTable.getColumnCount(); ++i) {
            col = logDataTable.getColumn(i);
            renderer = new CheckboxHeaderRenderer(i + 1, tableHeader);
            col.setHeaderRenderer(renderer);
            colName = col.getHeaderValue().toString();
            xAxisColumn.addItem(colName);
            yAxisColumn.addItem(colName);
            plotsColumn.addItem(colName);
            comp = renderer.getTableCellRendererComponent(logDataTable.getTable(), colName, false, false, 0, 0);
            col.setPreferredWidth(comp.getPreferredSize().width + 4);
            series = new XYSeries(colName);
            series.setDescription(colName);
            lcColName = colName.toLowerCase();
            dataset.addSeries(series);
            plotRenderer.setSeriesShapesVisible(i, false);
            plotRenderer.setSeriesVisible(i, false);
            selectionCombo.addItem(colName);
            listModel.addElement(new JLabel(colName, renderer.getCheckIcon(), JLabel.LEFT));
            if (rpmDataset.getSeriesCount() == 0
                    && (lcColName.matches(".*rpm.*") || lcColName.matches(".*eng.*speed.*"))) {
                rpmDataset.addSeries(series);
                rpmPlotRenderer.setSeriesShapesVisible(0, false);
                rpmPlotRenderer.setSeriesVisible(0, false);
                rpmCol = i;
            }
            for (int j = 0; j < logDataTable.getRowCount(); ++j) {
                try {
                    val = (String) logDataTable.getValueAt(j, i);
                    series.add(j, Double.valueOf(val), false);
                } catch (Exception e) {
                    JOptionPane.showMessageDialog(null,
                            "Invalid numeric value in column " + colName + ", row " + (j + 1), "Invalid value",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
            }
            series.fireSeriesChanged();
        }
        if (logDataTable.getControlPanel().getComponentCount() > 7)
            logDataTable.getControlPanel().remove(7);
        logDataTable.getControlPanel().add(new JLabel("   [" + file.getName() + "]"));
        initColors();
    } catch (Exception ex) {
        ex.printStackTrace();
        logger.error(ex);
    } finally {
        setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    }
}

From source file:org.rdv.ui.MainPanel.java

public void postState(int newState, int oldState) {
    if (newState == Player.STATE_DISCONNECTED) {
        frame.setTitle("RDV");

        controlAction.setEnabled(false);
        disconnectAction.setEnabled(false);
        saveAction.setEnabled(false);//from w  w w  .j  a v a2s  . c  om
        importAction.setEnabled(false);
        exportAction.setEnabled(false);

        controlPanel.setEnabled(false);
        markerSubmitPanel.setEnabled(false);

        ActionFactory.getInstance().getOfflineAction().setSelected(false);
    } else if (oldState == Player.STATE_DISCONNECTED) {
        frame.setTitle(rbnb.getServerName() + " - RDV");

        controlAction.setEnabled(true);
        disconnectAction.setEnabled(true);

        LocalServer localServer = LocalServer.getInstance();
        boolean offline = rbnb.getRBNBHostName().equals(localServer.getHost())
                && rbnb.getRBNBPortNumber() == localServer.getPort();
        saveAction.setEnabled(!offline);
        importAction.setEnabled(offline);
        exportAction.setEnabled(true);

        controlPanel.setEnabled(true);
        markerSubmitPanel.setEnabled(true);
    }

    if (newState == Player.STATE_LOADING || newState == Player.STATE_PLAYING
            || newState == Player.STATE_MONITORING) {
        startThrobber();
    } else if (oldState == Player.STATE_LOADING || oldState == Player.STATE_PLAYING
            || oldState == Player.STATE_MONITORING) {
        stopThrobber();
    }

    if (newState == Player.STATE_LOADING) {
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

        loadingDialog = new LoadingDialog(frame);

        new Thread() {
            public void run() {
                synchronized (loadingMonitor) {
                    if (loadingDialog == null) {
                        return;
                    }

                    try {
                        loadingMonitor.wait(1000);
                    } catch (InterruptedException e) {
                    }

                    if (loadingDialog != null) {
                        loadingDialog.setVisible(true);
                        loadingDialog.start();
                    }
                }
            }
        }.start();
    } else if (oldState == Player.STATE_LOADING) {
        setCursor(null);

        synchronized (loadingMonitor) {
            loadingMonitor.notify();

            if (loadingDialog != null) {
                loadingDialog.close();
                loadingDialog = null;
            }
        }
    }
}

From source file:neg.JRViewerComercialProveedor.java

void btnPrintActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnPrintActionPerformed
{//GEN-HEADEREND:event_btnPrintActionPerformed
 // Add your handling code here:

    Thread thread = new Thread(new Runnable() {
        public void run() {
            try {

                btnPrint.setEnabled(false);
                JRViewerComercialProveedor.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                JasperPrintManager.printReport(jasperPrint, true);
            } catch (Exception ex) {
                if (log.isErrorEnabled())
                    log.error("Print error.", ex);

                JOptionPane.showMessageDialog(JRViewerComercialProveedor.this,
                        getBundleString("error.printing"));
            } finally {
                JRViewerComercialProveedor.this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                btnPrint.setEnabled(true);
            }//w w w  . ja  v a  2 s .c o  m
        }
    });

    thread.start();

}

From source file:com.g2inc.scap.editor.gui.windows.EditorMainWindow.java

private void openMRUFile(File f) {
    SCAPDocument sdoc = null;//from  w ww  .j  a  v a 2  s.co m
    Charset alternateEncoding = Charset.forName("UTF-8");

    try {
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        sdoc = SCAPDocumentFactory.loadDocument(f, alternateEncoding);
        if (sdoc == null) {
            // if the document is null here it's probably an unsupported version
            throw new UnsupportedDocumentTypeException("The document type is not supported at this time");
        }
    } catch (UnsupportedDocumentTypeException udte) {
        setCursor(null);
        String message = "The document contained in file " + f.getAbsolutePath() + " could not be loaded: "
                + udte.getMessage();

        EditorUtil.showMessageDialog(this, message, EditorMessages.LOAD_DOCUMENT_ERROR_TITLE,
                JOptionPane.ERROR_MESSAGE);
        return;

    } catch (CharacterSetEncodingException e) {
        setCursor(null);
        AlternateEncodingPicker encPicker = new AlternateEncodingPicker(this, true);

        encPicker.pack();
        encPicker.setLocationRelativeTo(this);
        encPicker.setVisible(true);

        if (!encPicker.wasCancelled()) {
            alternateEncoding = encPicker.getSelectedEncoding();
        } else {
            setCursor(null);
            String message = "Opening of file " + f.getName() + " Cancelled: " + e.getMessage();

            EditorUtil.showMessageDialog(this, message, EditorMessages.LOAD_DOCUMENT_ERROR_TITLE,
                    JOptionPane.ERROR_MESSAGE);
            return;
        }
    } catch (IOException e) {
        setCursor(null);
        LOG.error("EXCEPTION", e);
        String message = "File " + f.getName() + " couldn't be opened because of an I/O issue: "
                + e.getMessage();

        EditorUtil.showMessageDialog(this, message, EditorMessages.LOAD_DOCUMENT_ERROR_TITLE,
                JOptionPane.ERROR_MESSAGE);
        return;
    } catch (Exception eee) {
        setCursor(null);
        LOG.error("Exception", eee);
        String message = "An exception occurred trying to open file " + f.getAbsolutePath()
                + ", see log file for details";
        EditorUtil.showMessageDialog(this, message, EditorMessages.LOAD_DOCUMENT_ERROR_TITLE,
                JOptionPane.ERROR_MESSAGE);
        return;
    }
    setCursor(null);

    if (sdoc != null) {
        openFile(sdoc);
    } else {
        String message = "There was a problem trying to open file " + f.getAbsolutePath()
                + ": document returned was NULL";
        EditorUtil.showMessageDialog(this, message, EditorMessages.LOAD_DOCUMENT_ERROR_TITLE,
                JOptionPane.ERROR_MESSAGE);
        return;
    }
}

From source file:neg.JRViewerInformeUnitario.java

void btnPrintActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnPrintActionPerformed
{//GEN-HEADEREND:event_btnPrintActionPerformed
 // Add your handling code here:

    Thread thread = new Thread(new Runnable() {
        public void run() {
            try {

                btnPrint.setEnabled(false);
                JRViewerInformeUnitario.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                JasperPrintManager.printReport(jasperPrint, true);
            } catch (Exception ex) {
                if (log.isErrorEnabled())
                    log.error("Print error.", ex);

                JOptionPane.showMessageDialog(JRViewerInformeUnitario.this, getBundleString("error.printing"));
            } finally {
                JRViewerInformeUnitario.this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                btnPrint.setEnabled(true);
            }/*w  w  w . j a  v  a 2  s  .c om*/
        }
    });

    thread.start();

}

From source file:neg.JRViewerComercial.java

void btnPrintActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnPrintActionPerformed
{//GEN-HEADEREND:event_btnPrintActionPerformed
 // Add your handling code here:

    Thread thread = new Thread(new Runnable() {
        public void run() {
            try {

                btnPrint.setEnabled(false);
                JRViewerComercial.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                JasperPrintManager.printReport(jasperPrint, true);
            } catch (Exception ex) {
                if (log.isErrorEnabled())
                    log.error("Print error.", ex);

                JOptionPane.showMessageDialog(JRViewerComercial.this, getBundleString("error.printing"));
            } finally {
                JRViewerComercial.this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                btnPrint.setEnabled(true);
            }/*  w w  w.j  av a 2s .  c o m*/
        }
    });

    thread.start();

}

From source file:ireport_5_6_0.view.JRViewer.java

void btnPrintActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPrintActionPerformed
    //GEN-HEADEREND:event_btnPrintActionPerformed
    // Add your handling code here:
    Thread thread = new Thread(new Runnable() {
        @Override//from  w w  w  .  j a v  a 2s.c o  m
        public void run() {
            try {

                btnPrint.setEnabled(false);
                JRViewer.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                JasperPrintManager.getInstance(jasperReportsContext).print(jasperPrint, true);
            } catch (Exception ex) {
                if (log.isErrorEnabled()) {
                    log.error("Print error.", ex);
                }
                JOptionPane.showMessageDialog(JRViewer.this, getBundleString("error.printing"));
            } finally {
                JRViewer.this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                btnPrint.setEnabled(true);
            }
        }
    });
    thread.start();
}