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:com.g2inc.scap.editor.gui.windows.EditorMainWindow.java

private void openMRUFile(File f) {
    SCAPDocument sdoc = null;// w  w  w  .jav  a  2 s  .c  o  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);
            }//from  w  ww. j  a  v  a 2 s  . c o m
        }
    });

    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  a va 2  s.com
        }
    });

    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  www . j  a  v  a  2 s. 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();
}

From source file:neg.JRViewerSin.java

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

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

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

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

    thread.start();
}

From source file:org.gumtree.vis.awt.JChartPanel.java

@Override
public void mouseMoved(MouseEvent e) {
    //        if (isMaskingEnabled() && (e.getModifiers() & maskingKeyMask) != 0) {
    if (selectedTextWrapper == null && isMaskingEnabled()) {
        int cursorType = findCursorOnSelectedItem(e.getX(), e.getY());
        setCursor(Cursor.getPredefinedCursor(cursorType));
    } else {//w  w  w .j a v  a  2 s. co  m
        Cursor newCursor = defaultCursor;
        if (selectedTextWrapper != null) {
            Point2D screenXY = ChartMaskingUtilities.translateChartPoint(
                    new Point2D.Double(selectedTextWrapper.getMinX(), selectedTextWrapper.getMinY()),
                    getScreenDataArea(), getChart());
            Rectangle2D screenRect = new Rectangle2D.Double(screenXY.getX(), screenXY.getY() - 15,
                    selectedTextWrapper.getWidth(), selectedTextWrapper.getHeight());
            if (screenRect.contains(e.getX(), e.getY())) {
                newCursor = Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR);
            }
        }
        if (newCursor != getCursor()) {
            setCursor(newCursor);
        }
    }
    Line2D oldSelection = selectedMarker;
    findSelectedMarker(e.getPoint());
    if (selectedMarker != oldSelection) {
        repaint();
    }
}

From source file:op.care.dfn.PnlDFN.java

private List<Component> addFilters() {
    List<Component> list = new ArrayList<Component>();

    jdcDate = new JDateChooser(new Date());
    jdcDate.setFont(new Font("Arial", Font.PLAIN, 14));

    jdcDate.setBackground(Color.WHITE);

    list.add(jdcDate);//w  ww. j av a2  s.c o m

    JPanel buttonPanel = new JPanel();
    buttonPanel.setBackground(Color.WHITE);
    buttonPanel.setLayout(new HorizontalLayout(5));
    buttonPanel.setBorder(new EmptyBorder(0, 0, 0, 0));

    final JButton homeButton = new JButton(
            new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_start.png")));
    homeButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            jdcDate.setDate(jdcDate.getMinSelectableDate());
        }
    });
    homeButton.setPressedIcon(
            new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_start_pressed.png")));
    homeButton.setBorder(null);
    homeButton.setBorderPainted(false);
    homeButton.setOpaque(false);
    homeButton.setContentAreaFilled(false);
    homeButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

    final JButton backButton = new JButton(
            new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_back.png")));
    backButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            DateMidnight current = new DateMidnight(jdcDate.getDate());
            DateMidnight min = new DateMidnight(jdcDate.getMinSelectableDate());
            if (current.equals(min)) {
                return;
            }
            jdcDate.setDate(SYSCalendar.addDate(jdcDate.getDate(), -1));
        }
    });
    backButton
            .setPressedIcon(new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_back_pressed.png")));
    backButton.setBorder(null);
    backButton.setBorderPainted(false);
    backButton.setOpaque(false);
    backButton.setContentAreaFilled(false);
    backButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

    final JButton fwdButton = new JButton(
            new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_play.png")));
    fwdButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            DateMidnight current = new DateMidnight(jdcDate.getDate());
            if (current.equals(new DateMidnight())) {
                return;
            }
            jdcDate.setDate(SYSCalendar.addDate(jdcDate.getDate(), 1));
        }
    });
    fwdButton
            .setPressedIcon(new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_play_pressed.png")));
    fwdButton.setBorder(null);
    fwdButton.setBorderPainted(false);
    fwdButton.setOpaque(false);
    fwdButton.setContentAreaFilled(false);
    fwdButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

    final JButton endButton = new JButton(
            new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_end.png")));
    endButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            jdcDate.setDate(new Date());
        }
    });
    endButton.setPressedIcon(new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_end_pressed.png")));
    endButton.setBorder(null);
    endButton.setBorderPainted(false);
    endButton.setOpaque(false);
    endButton.setContentAreaFilled(false);
    endButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

    buttonPanel.add(homeButton);
    buttonPanel.add(backButton);
    buttonPanel.add(fwdButton);
    buttonPanel.add(endButton);

    list.add(buttonPanel);

    jdcDate.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (initPhase) {
                return;
            }
            if (evt.getPropertyName().equals("date")) {
                reloadDisplay();
            }
        }
    });

    return list;
}

From source file:lejos.pc.charting.LogChartFrame.java

/** Attempt to start a connection using a thread so the GUI stays responsive. Manage connect button state
 * @param e//  ww  w. j a v a  2 s . c om
 */
private void jButtonConnect_actionPerformed(ActionEvent e) {
    final ActionEvent ee = e;
    Runnable doAction = new Runnable() {
        public void run() {
            if (jButtonConnect.getText().equals("Connect")) {
                if (!isNXTConnected) {
                    jButtonConnect.setText("Connecting..");
                    jButtonConnect.setEnabled(false);
                    LogChartFrame.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    if (makeConnection()) {
                        jButtonConnect.setText("Disconnect");
                    } else {
                        jButtonConnect.setText("Connect");
                    }
                    LogChartFrame.this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                    jButtonConnect.setEnabled(true);
                }

                System.out.println(ee.getActionCommand().toString());
            } else {
                closeCurrentConnection();
            }
        }
    };
    new Thread(doAction).start();
}

From source file:org.isatools.isacreator.spreadsheet.Spreadsheet.java

protected void highlight(String toGroupBy, boolean exactMatch, boolean returnSampleNames) {
    if (tableGroupInformation != null && tableGroupInformation.isShowing()) {
        tableGroupInformation.dispose();
    }//  w ww . j ava2s . c o m

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

    Map<String, List<Object>> groups = getDataGroupsByColumn(toGroupBy, exactMatch, returnSampleNames);

    Map<String, Color> groupColors = new ListOrderedMap<String, Color>();

    for (String s : groups.keySet()) {
        groupColors.put(s, UIHelper.createColorFromString(s, true));
    }
    // then pass the groups and the colours to the TableGroupInfo class to display the gui
    // showing group distribution!
    final Map<Integer, Color> rowColors = paintRows(groups, groupColors);

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

    tableGroupInformation = new TableGroupInfo(groups, groupColors, table.getRowCount());
    tableGroupInformation.setLocation(getWidth() / 2 - tableGroupInformation.getWidth(),
            getHeight() / 2 - tableGroupInformation.getHeight());
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {

            try {
                table.setDefaultRenderer(Class.forName("java.lang.Object"),
                        new CustomRowRenderer(rowColors, UIHelper.VER_11_PLAIN));
                table.repaint();
                tableGroupInformation.createGUI();
                highlightActive = true;
            } catch (ClassNotFoundException e) {
                //
            }
        }
    });
}

From source file:lejos.pc.charting.LogChartFrame.java

private void selectFolderButton_actionPerformed(ActionEvent e) {
    this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    JFileChooser jfc = new JFileChooser(new File(FQPathTextArea.getText(), ""));
    jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    jfc.setApproveButtonText("Select");
    jfc.setDialogTitle("Select Directory");
    jfc.setDialogType(JFileChooser.OPEN_DIALOG);
    this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    int returnVal = jfc.showOpenDialog(this);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        FQPathTextArea.setText(getCanonicalName(jfc.getSelectedFile()));
        jfc.setCurrentDirectory(jfc.getSelectedFile());
        System.out.println("folder set to \"" + getCanonicalName(jfc.getSelectedFile()) + "\"");
    }//w  ww.  j a v  a 2  s . c  om
}