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.floreantpos.config.ui.DatabaseConfigurationDialog.java

public void actionPerformed(ActionEvent e) {
    try {//  ww  w  .j  a v  a 2s .c  om
        String command = e.getActionCommand();

        Database selectedDb = (Database) databaseCombo.getSelectedItem();

        final String providerName = selectedDb.getProviderName();
        final String databaseURL = tfServerAddress.getText();
        final String databasePort = tfServerPort.getText();
        final String databaseName = tfDatabaseName.getText();
        final String user = tfUserName.getText();
        final String pass = new String(tfPassword.getPassword());

        final String connectionString = selectedDb.getConnectString(databaseURL, databasePort, databaseName);
        final String hibernateDialect = selectedDb.getHibernateDialect();
        final String driverClass = selectedDb.getHibernateConnectionDriverClass();

        if (CANCEL.equalsIgnoreCase(command)) {
            dispose();
            return;
        }

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

        Application.getInstance().setSystemInitialized(false);
        saveConfig(selectedDb, providerName, databaseURL, databasePort, databaseName, user, pass,
                connectionString, hibernateDialect);

        if (TEST.equalsIgnoreCase(command)) {
            try {
                DatabaseUtil.checkConnection(connectionString, hibernateDialect, driverClass, user, pass);
            } catch (DatabaseConnectionException e1) {
                JOptionPane.showMessageDialog(this, Messages.getString("DatabaseConfigurationDialog.32")); //$NON-NLS-1$
                return;
            }

            connectionSuccess = true;
            JOptionPane.showMessageDialog(this, Messages.getString("DatabaseConfigurationDialog.31")); //$NON-NLS-1$
        } else if (UPDATE_DATABASE.equals(command)) {
            int i = JOptionPane.showConfirmDialog(this, Messages.getString("DatabaseConfigurationDialog.0"), //$NON-NLS-1$
                    Messages.getString("DatabaseConfigurationDialog.1"), JOptionPane.YES_NO_OPTION); //$NON-NLS-1$
            if (i != JOptionPane.YES_OPTION) {
                return;
            }

            //isAuthorizedToPerformDbChange();

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

            boolean databaseUpdated = DatabaseUtil.updateDatabase(connectionString, hibernateDialect,
                    driverClass, user, pass);
            if (databaseUpdated) {
                connectionSuccess = true;
                JOptionPane.showMessageDialog(DatabaseConfigurationDialog.this,
                        Messages.getString("DatabaseConfigurationDialog.2")); //$NON-NLS-1$
            } else {
                JOptionPane.showMessageDialog(DatabaseConfigurationDialog.this,
                        Messages.getString("DatabaseConfigurationDialog.3")); //$NON-NLS-1$
            }
        } else if (CREATE_DATABASE.equals(command)) {

            int i = JOptionPane.showConfirmDialog(this, Messages.getString("DatabaseConfigurationDialog.33"), //$NON-NLS-1$
                    Messages.getString("DatabaseConfigurationDialog.34"), JOptionPane.YES_NO_OPTION); //$NON-NLS-1$
            if (i != JOptionPane.YES_OPTION) {
                return;
            }

            i = JOptionPane.showConfirmDialog(this, Messages.getString("DatabaseConfigurationDialog.4"), //$NON-NLS-1$
                    Messages.getString("DatabaseConfigurationDialog.5"), JOptionPane.YES_NO_OPTION); //$NON-NLS-1$
            boolean generateSampleData = false;
            if (i == JOptionPane.YES_OPTION)
                generateSampleData = true;

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

            String createDbConnectString = selectedDb.getCreateDbConnectString(databaseURL, databasePort,
                    databaseName);

            boolean databaseCreated = DatabaseUtil.createDatabase(createDbConnectString, hibernateDialect,
                    driverClass, user, pass, generateSampleData);

            if (databaseCreated) {
                JOptionPane.showMessageDialog(DatabaseConfigurationDialog.this,
                        Messages.getString("DatabaseConfigurationDialog.6") + //$NON-NLS-1$
                                Messages.getString("DatabaseConfigurationDialog.7")); //$NON-NLS-1$

                Main.restart();
                connectionSuccess = true;
            } else {
                JOptionPane.showMessageDialog(DatabaseConfigurationDialog.this,
                        Messages.getString("DatabaseConfigurationDialog.36")); //$NON-NLS-1$
            }
        } else if (SAVE.equalsIgnoreCase(command)) {
            if (connectionSuccess) {
                Application.getInstance().initializeSystem();
            }
            dispose();
        }
    } catch (Exception e2) {
        PosLog.error(getClass(), e2);
        POSMessageDialog.showMessage(this, e2.getMessage());
    } finally {
        setCursor(Cursor.getDefaultCursor());
    }
}

From source file:edu.scripps.fl.pubchem.xmltool.gui.PubChemXMLCreatorGUI.java

public void mouseClicked(MouseEvent e) {
    try {/*from w  w  w  .java 2 s. c  o m*/
        if (e.getClickCount() > 0) {
            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            if (e.getSource() == jtpExample) {
                URL url = getClass().getClassLoader().getResource("ExampleExcel.xlsx");
                File tmpFile = File.createTempFile("example", ".xlsx");
                FileUtils.copyURLToFile(url, tmpFile);
                tmpFile.deleteOnExit();
                Desktop.getDesktop().open(tmpFile);
            } else if (e.getSource() == jtpExcelTemplate) {
                File saveFile = gc.fileChooser(jtfFileExcel, ".xlsx", "save");
                if (saveFile != null) {
                    URL url = getClass().getClassLoader().getResource("ExcelTemplate_withBAO.xlsx");
                    OutputStream out = new FileOutputStream(saveFile, true);
                    IOUtils.copy(url.openStream(), out);
                    String output = FilenameUtils.concat(FilenameUtils.getFullPath(saveFile.toString()),
                            FilenameUtils.getBaseName(saveFile.toString()));
                    Desktop.getDesktop().open(new File(saveFile.toString()));
                }
            } else if (e.getSource() == jtfFileTemplate && jtfFileTemplate.getText().equals(template)) {
                jtfFileTemplate.setText("");
            } else if (e.getSource() == this) {
                if (jtfFileTemplate.getText().equals("")) {
                    jtfFileTemplate.setText(template);
                }
            }
        }
        setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    } catch (Throwable throwable) {
        SwingGUI.handleError(this, throwable);
    }
}

From source file:com.floreantpos.config.ui.DatabaseConfigurationView.java

public void actionPerformed(ActionEvent e) {
    try {/*from  w  w  w. java2  s.  c o  m*/
        String command = e.getActionCommand();

        Database selectedDb = (Database) databaseCombo.getSelectedItem();

        String providerName = selectedDb.getProviderName();
        String databaseURL = tfServerAddress.getText();
        String databasePort = tfServerPort.getText();
        String databaseName = tfDatabaseName.getText();
        String user = tfUserName.getText();
        String pass = new String(tfPassword.getPassword());

        String connectionString = selectedDb.getConnectString(databaseURL, databasePort, databaseName);
        String hibernateDialect = selectedDb.getHibernateDialect();
        String driverClass = selectedDb.getHibernateConnectionDriverClass();

        if (TEST.equalsIgnoreCase(command)) {
            Application.getInstance().setSystemInitialized(false);
            saveConfig(selectedDb, providerName, databaseURL, databasePort, databaseName, user, pass,
                    connectionString, hibernateDialect);

            try {
                DatabaseUtil.checkConnection(connectionString, hibernateDialect, driverClass, user, pass);
            } catch (DatabaseConnectionException e1) {
                JOptionPane.showMessageDialog(this, Messages.getString("DatabaseConfigurationDialog.32")); //$NON-NLS-1$
                return;
            }

            JOptionPane.showMessageDialog(POSUtil.getBackOfficeWindow(),
                    Messages.getString("DatabaseConfigurationDialog.31")); //$NON-NLS-1$
        } else if (CONFIGURE_DB.equals(command)) {
            Application.getInstance().setSystemInitialized(false);

            int i = JOptionPane.showConfirmDialog(POSUtil.getBackOfficeWindow(),
                    Messages.getString("DatabaseConfigurationDialog.33"), //$NON-NLS-1$
                    Messages.getString("DatabaseConfigurationDialog.34"), JOptionPane.YES_NO_OPTION); //$NON-NLS-1$
            if (i != JOptionPane.YES_OPTION) {
                return;
            }

            i = JOptionPane.showConfirmDialog(POSUtil.getBackOfficeWindow(),
                    Messages.getString("DatabaseConfigurationView.3"), //$NON-NLS-1$
                    Messages.getString("DatabaseConfigurationView.4"), JOptionPane.YES_NO_OPTION); //$NON-NLS-1$
            boolean generateSampleData = false;
            if (i == JOptionPane.YES_OPTION)
                generateSampleData = true;

            saveConfig(selectedDb, providerName, databaseURL, databasePort, databaseName, user, pass,
                    connectionString, hibernateDialect);

            String connectionString2 = selectedDb.getCreateDbConnectString(databaseURL, databasePort,
                    databaseName);

            this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            boolean createDatabase = DatabaseUtil.createDatabase(connectionString2, hibernateDialect,
                    driverClass, user, pass, generateSampleData);
            this.setCursor(Cursor.getDefaultCursor());

            if (createDatabase) {
                //JOptionPane.showMessageDialog(DatabaseConfigurationView.this, Messages.getString("DatabaseConfigurationDialog.35")); //$NON-NLS-1$
                JOptionPane.showMessageDialog(POSUtil.getBackOfficeWindow(),
                        "Database created. Default password is 1111.\n\nThe system will now restart."); //$NON-NLS-1$

                Main.restart();
            } else {
                JOptionPane.showMessageDialog(POSUtil.getBackOfficeWindow(),
                        Messages.getString("DatabaseConfigurationDialog.36")); //$NON-NLS-1$
            }
        } else if (SAVE.equalsIgnoreCase(command)) {
            Application.getInstance().setSystemInitialized(false);
            saveConfig(selectedDb, providerName, databaseURL, databasePort, databaseName, user, pass,
                    connectionString, hibernateDialect);
        } else if (CANCEL.equalsIgnoreCase(command)) {
        }
    } catch (Exception e2) {
        POSMessageDialog.showMessage(com.floreantpos.util.POSUtil.getBackOfficeWindow(), e2.getMessage());
    }
}

From source file:grisu.frontend.view.swing.jobmonitoring.single.appSpecific.Gold.java

private JButton getBtnHistory() {
    if (btnHistory == null) {
        btnHistory = new JButton("History");
        btnHistory.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {

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

                File temp;// ww  w.j  a v a 2  s  .  c o  m
                try {
                    temp = downloadJobStatusFile();
                } catch (final FileTransactionException e1) {
                    final ErrorInfo ei = new ErrorInfo("Download error",
                            "Error while trying to download job status file.", e1.getLocalizedMessage(),
                            (String) null, e1, Level.SEVERE, (Map) null);
                    JXErrorPane.showDialog(Gold.this.getPanel(), ei);
                    return;
                }

                final JobStatusFileDialog dialog = new JobStatusFileDialog();
                dialog.setFileManagerAndUrl(fm, job_status_url);
                dialog.setFile(null, temp);
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                dialog.setVisible(true);

            }
        });
    }
    return btnHistory;
}

From source file:grisu.frontend.view.swing.files.preview.fileViewers.JobStatusGridFileViewer.java

private JCheckBox getChckbxShowMinutes() {
    if (chckbxShowMinutes == null) {
        chckbxShowMinutes = new JCheckBox("Display minutes");
        chckbxShowMinutes.addItemListener(new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
                if (chckbxShowMinutes.isSelected()) {
                    showMinutes = true;//  w  ww . j a v a 2 s.com
                } else {
                    showMinutes = false;
                }

                new Thread() {
                    @Override
                    public void run() {
                        chckbxShowMinutes.setEnabled(false);
                        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                        generateGraph();
                        setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                        chckbxShowMinutes.setEnabled(true);
                    }
                }.start();

            }
        });
    }
    return chckbxShowMinutes;
}

From source file:org.roche.antibody.ui.components.AntibodyEditorPane.java

public void setModel(Antibody ab) {
    mainEditor.getFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    this.antibody = ab;
    this.graphSyncer = new GraphSynchronizer(mainEditor, this, ab);
    createGraph();/* ww w  .j  a v a 2 s  . co  m*/
    updateHELMTextArea();
    mainEditor.reset();
    mainEditor.getFrame().setCursor(Cursor.getDefaultCursor());
    updateGraphLayout();
    isBackToDomainEditorEnabled = false;
}

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

public void restartMirthWorker() {
    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 = restartMirth();
            return null;
        }/*from  w w  w  .  j a va2  s  .  c o  m*/

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

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

    worker.execute();
}

From source file:ca.phon.app.session.editor.view.segmentation.SegmentationEditorView.java

private void updateParticipantPanel() {
    participantPanel.removeAll();//  ww w.jav  a 2 s.c o m

    // setup layout
    String colLayout = "fill:default";
    String rowLayout = "pref, 5px";
    for (int i = 0; i <= getEditor().getSession().getParticipantCount(); i++) {
        rowLayout += ", pref, 5px";
    }
    FormLayout layout = new FormLayout(colLayout, rowLayout);
    participantPanel.setLayout(layout);
    CellConstraints cc = new CellConstraints();
    int currentRow = 1;

    String ksStr = (OSInfo.isMacOs() ? "\u2318" : "CTRL +") + "0";
    PhonUIAction noPartSegmentAct = new PhonUIAction(this, "performSegmentation", null);
    noPartSegmentAct.putValue(Action.NAME, ksStr + " speaker undefined");

    // setup labels to be used like buttons
    String segMsg = "Click name to create a new record:";
    JLabel segLbl = new JLabel(segMsg);

    participantPanel.add(segLbl, cc.xy(1, currentRow));
    currentRow += 2;

    JLabel noPartLbl = new JLabel();
    String noPartMsg = ksStr + " <no speaker>";
    noPartLbl.setText(noPartMsg);
    noPartLbl.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    noPartLbl.addMouseListener(new SegmentLabelMouseHandler());
    noPartLbl.setOpaque(false);
    participantPanel.add(noPartLbl, cc.xy(1, currentRow));
    currentRow += 2;

    final Session session = getEditor().getSession();
    int pIdx = 1;
    for (Participant p : session.getParticipants()) {
        ksStr = (OSInfo.isMacOs() ? "\u2318" : "CTRL +") + pIdx;

        final NewSegmentAction segmentAction = new NewSegmentAction(getEditor(), this, p);
        segmentAction.putValue(Action.NAME, ksStr + " " + p.toString());

        JLabel participantLbl = new JLabel();
        String participantStr = ksStr + " " + (p.getName() != null ? p.getName() : p.getId());
        participantLbl.setText(participantStr);
        participantLbl.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        participantLbl.addMouseListener(new SegmentLabelMouseHandler(p));
        participantLbl.setOpaque(false);
        participantPanel.add(participantLbl, cc.xy(1, currentRow));
        currentRow += 2;

        pIdx++;
    }
}

From source file:org.yccheok.jstock.gui.LoadFromCloudJDialog.java

private void jLabel5MouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel5MouseEntered
    this.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}

From source file:de.unibayreuth.bayeos.goat.panels.timeseries.JPanelChart.java

private void setPanMode(boolean val) {

    this.chartPanel.setHorizontalZoom(!val);
    // chartPanel.setHorizontalAxisTrace(! val);
    this.chartPanel.setVerticalZoom(!val);
    // chartPanel.setVerticalAxisTrace(! val);

    if (val) {
        this.chartPanel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    } else {//w w w  .j  av  a 2 s .  c om
        this.chartPanel.setCursor(Cursor.getDefaultCursor());
    }
}