Example usage for java.awt Cursor getDefaultCursor

List of usage examples for java.awt Cursor getDefaultCursor

Introduction

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

Prototype

public static Cursor getDefaultCursor() 

Source Link

Document

Return the system default cursor.

Usage

From source file:org.openmicroscopy.shoola.agents.metadata.editor.EditorUI.java

/** Clears data to save. */
void clearData() {
    saved = false;/*from w w w.  j  a  va 2  s  .c  o  m*/
    userUI.clearData(null);
    groupUI.clearData(null);
    generalPane.clearData(null);
    tabPane.setComponentAt(RND_INDEX, dummyPanel);
    tabPane.repaint();
    setCursor(Cursor.getDefaultCursor());
}

From source file:DragDropTreeExample.java

public void drop(DropTargetDropEvent dtde) {
    DnDUtils.debugPrintln("DropTarget drop, drop action = " + DnDUtils.showActions(dtde.getDropAction()));

    // Check the drop action
    if ((dtde.getDropAction() & DnDConstants.ACTION_COPY_OR_MOVE) != 0) {
        // Accept the drop and get the transfer data
        dtde.acceptDrop(dtde.getDropAction());
        Transferable transferable = dtde.getTransferable();
        boolean dropSucceeded = false;

        try {//from   w  w  w  .j a v  a2 s .c  om
            tree.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

            // Save the user's selections
            saveTreeSelection();

            dropSucceeded = dropFile(dtde.getDropAction(), transferable, dtde.getLocation());

            DnDUtils.debugPrintln("Drop completed, success: " + dropSucceeded);
        } catch (Exception e) {
            DnDUtils.debugPrintln("Exception while handling drop " + e);
        } finally {
            tree.setCursor(Cursor.getDefaultCursor());

            // Restore the user's selections
            restoreTreeSelection();
            dtde.dropComplete(dropSucceeded);
        }
    } else {
        DnDUtils.debugPrintln("Drop target rejected drop");
        dtde.dropComplete(false);
    }
}

From source file:com.ivli.roim.controls.ChartControl.java

@Override
public void mouseMoved(MouseEvent e) {
    super.mouseMoved(e);

    if (null == iEntity && null == iMarker) {
        ChartEntity entity = findEntity(e);
        if (entity instanceof XYItemEntity) {
            setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        } else if (entity instanceof PlotEntity) {

            if (null != findMarker(e))
                setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            else/*from   w  w w.j a  v  a2 s. co m*/
                setCursor(Cursor.getDefaultCursor());
        } else {
            setCursor(Cursor.getDefaultCursor());
        }
    }
}

From source file:com.unicornlabs.kabouter.gui.power.PowerPanel.java

private void applyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_applyButtonActionPerformed

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

    liveStatus = liveCheckBox.isSelected();
    List selectedValuesList = deviceList.getSelectedValuesList();

    if (liveStatus == true) {
        Calendar cal = Calendar.getInstance();
        Date currentDate = new Date();
        cal.setTime(currentDate);//from   w  w w.j  a v a 2  s . co m
        cal.add(Calendar.SECOND, -MAX_DATA_POINTS_LIVE);
        Date startDate = cal.getTime();

        ArrayList<Powerlog> logs = theHistorian.getPowerlogs(selectedValuesList, startDate, currentDate,
                MAX_DATA_POINTS_LIVE);

        setupChart(logs, "Live Power");

    } else {

        Calendar cal = Calendar.getInstance();
        cal.setTime((Date) startTimeSpinner.getValue());

        int hour = cal.get(Calendar.HOUR_OF_DAY);
        int min = cal.get(Calendar.MINUTE);
        int sec = cal.get(Calendar.SECOND);

        cal.setTime(startDateChooser.getDate());

        cal.set(Calendar.HOUR_OF_DAY, hour);
        cal.set(Calendar.MINUTE, min);
        cal.set(Calendar.SECOND, sec);

        Date start = cal.getTime();

        cal.setTime((Date) endTimeSpinner.getValue());

        hour = cal.get(Calendar.HOUR_OF_DAY);
        min = cal.get(Calendar.MINUTE);
        sec = cal.get(Calendar.SECOND);

        cal.setTime(endDateChooser.getDate());

        cal.set(Calendar.HOUR_OF_DAY, hour);
        cal.set(Calendar.MINUTE, min);
        cal.set(Calendar.SECOND, sec);

        Date end = cal.getTime();

        ArrayList<Powerlog> logs = theHistorian.getPowerlogs(selectedValuesList, start, end, MAX_DATA_POINTS);

        setupChart(logs, "Power");
    }

    setCursor(Cursor.getDefaultCursor());

}

From source file:AltiConsole.AltiConsoleMainScreen.java

public boolean ConnectToAlti() {
    long timeOut = 10000;
    if (UserPref.getRetrievalTimeout() != null && UserPref.getRetrievalTimeout() != "")
        timeOut = Long.decode(UserPref.getRetrievalTimeout());
    System.out.println("timeOut " + timeOut);
    if (Serial.getConnected() == true) {
        System.out.println("I am already connected... let's disconnect\n");
        Serial.disconnect();// w w  w. j  ava  2  s.  c  om
        //Serial.DataReady = false;
        Serial.setDataReady(false);
    }

    /* Connect */
    Serial.connect();
    //while (Serial.getConnected() != true);
    if (Serial.getConnected() == true) {
        if (Serial.initIOStream() == true) {
            if (Serial.initListener() == true) {
                // send command to switch off the continuity test
                //Serial.DataReady = false;
                Serial.clearInput();
                Serial.setDataReady(false);
                Serial.writeData("f;\n");
                System.out.println("f;\n");
                long startTime; // 
                Serial.lastReceived = System.currentTimeMillis();
                while (Serial.getDataReady() != true) {
                    long currentTime = System.currentTimeMillis();
                    startTime = Serial.lastReceived;
                    if ((currentTime - startTime) > timeOut) {
                        // This is some sort of data retrieval timeout
                        System.out.println("ConnectToAlti - Data retrieval timed out\n");
                        this.setCursor(Cursor.getDefaultCursor());
                        JOptionPane.showMessageDialog(null, trans.get("AltiConsoleMainScreen.dataTimeOut"),
                                trans.get("AltiConsoleMainScreen.ConnectionError"), JOptionPane.ERROR_MESSAGE);
                        return false;
                    }
                }
                System.out.println("ConnectToAlti - " + Serial.commandRet);
                //System.out.println("Data retrieval timed out\n");
                //Serial.DataReady = false;
                Serial.clearInput();
                Serial.setDataReady(false);
                Serial.writeData("f;\n");
                //startTime = System.currentTimeMillis();
                Serial.lastReceived = System.currentTimeMillis();
                System.out.println("ConnectToAlti - 2");
                if (Serial.getDataReady())
                    System.out.println("ConnectToAlti - 2 true");
                while (Serial.getDataReady() != true) {
                    try {
                        Thread.sleep(500);
                    } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    long currentTime = System.currentTimeMillis();
                    startTime = Serial.lastReceived;
                    if ((currentTime - startTime) > timeOut) {
                        // This is some sort of data retrieval timeout
                        System.out.println("ConnectToAlti - Data retrieval timed out1\n");
                        this.setCursor(Cursor.getDefaultCursor());
                        JOptionPane.showMessageDialog(null, trans.get("AltiConsoleMainScreen.dataTimeOut"),
                                trans.get("AltiConsoleMainScreen.ConnectionError"), JOptionPane.ERROR_MESSAGE);

                        return false;
                    }
                }
                System.out.println("ConnectToAlti - 2 I am out");
                //Serial.DataReady = false;
                Serial.setDataReady(false);

            }
        }
    }
    return true;
}

From source file:de.juwimm.cms.content.panel.PanDocuments.java

public void regionSelected() {
    setCursor(new Cursor(Cursor.WAIT_CURSOR));
    Integer intSelItem = ((CboModel) this.cboRegion.getSelectedItem()).getRegionId();
    loadThumbs(intSelItem);/*from   w  w  w. ja  v  a 2s  . co  m*/
    try {
        if (intRootUnit.equals(intSelItem)) {
            if (comm.isUserInRole(UserRights.SITE_ROOT) || intActUnit.equals(intRootUnit)) {
                this.btnDelete.setVisible(true);
                this.btnAdd.setVisible(true);
                this.btnPreview.setVisible(true);
            } else {
                this.btnDelete.setVisible(false);
                this.btnAdd.setVisible(false);
                this.btnPreview.setVisible(false);
            }
        } else {
            this.btnDelete.setVisible(true);
            this.btnAdd.setVisible(true);
            this.btnPreview.setVisible(true);
        }
    } catch (Exception ex) {
    }
    setCursor(Cursor.getDefaultCursor());
}

From source file:com.floreantpos.main.SetUpWindow.java

public void actionPerformed(ActionEvent e) {
    try {/*from   w w w. j av  a  2 s  .  c o m*/
        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)) {
            System.exit(1);
            return;
        }

        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        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$
            return;
        }
        saveConfig(selectedDb, providerName, databaseURL, databasePort, databaseName, user, pass,
                connectionString, hibernateDialect);
        if (CREATE_SAMPLE_DATA.equals(command)) {
            DataImportAction
                    .importMenuItems(DatabaseUtil.class.getResourceAsStream("/floreantpos-menu-items.xml")); //$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(SetUpWindow.this,
                        Messages.getString("DatabaseConfigurationDialog.6") + //$NON-NLS-1$
                                Messages.getString("DatabaseConfigurationDialog.7")); //$NON-NLS-1$
                connectionSuccess = true;
            } else {
                JOptionPane.showMessageDialog(SetUpWindow.this,
                        Messages.getString("DatabaseConfigurationDialog.36")); //$NON-NLS-1$
            }
        } else if (SAVE.equalsIgnoreCase(command)) {
            Integer terminalId = tfTerminalNumber.getInteger();
            Integer defaultPassLen = tfSecretKeyLength.getInteger();
            Integer autoLogOffTime = tfLogoffTime.getInteger();
            Boolean isLogOff = chkAutoLogoff.isSelected();
            Double scaleFactor = tfScaleFactor.getDouble();

            TerminalConfig.setTerminalId(terminalId);
            TerminalConfig.setDefaultPassLen(defaultPassLen);
            TerminalConfig.setScreenScaleFactor(scaleFactor);
            TerminalConfig.setAutoLogoffEnable(isLogOff);
            TerminalConfig.setAutoLogoffTime(autoLogOffTime <= 0 ? 10 : autoLogOffTime);
            try {
                DatabaseUtil.initialize();
                saveConfigData();
            } catch (Exception ex) {
                int i = JOptionPane.showConfirmDialog(this, "Connection Failed. Do you want to save?", //$NON-NLS-1$
                        "Connection status!", JOptionPane.YES_NO_OPTION); //$NON-NLS-1$
                if (i == JOptionPane.YES_OPTION) {
                    System.exit(1);
                }
            }
        }
    } catch (Exception e2) {
        PosLog.error(getClass(), e2);
        POSMessageDialog.showMessage(this, e2.getMessage());
    } finally {
        setCursor(Cursor.getDefaultCursor());
    }
}

From source file:rita.widget.SourceCode.java

private void createCompileButton() {
    ImageIcon imgIcon = new ImageIcon(getClass().getResource("/images/sourcecode/bytecode.png"));
    this.compileButton = new JButton(imgIcon);
    this.compileButton.setToolTipText(Language.get("compileButton.tooltip"));
    final File basePathRobots = new File(Settings.getRobotsPath());
    compileButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                // guardar el codigo fuente
                File sourcePath = saveSourceCode();
                // COMPILA EN EL DIRECTORIO POR DEFAULT + LA RUTA DEL PACKAGE
                Collection<File> inFiles = createClassFiles(sourcePath);
                if (inFiles != null) {
                    /* transformar el codigo fuente, que no tiene errores, para que los println aparezcan en una ventana.
                     * La transformacin no deberia generar errores.
                     *///w w w .  j a v a2s .c  o m
                    writeSourceFile(sourcePath,
                            AgregadorDeConsola.getInstance().transformar(readSourceFile(sourcePath)));
                    // volver a compilar, ahora con el codigo transformado

                    inFiles = createClassFiles(sourcePath);
                    if (inFiles != null) {
                        createJarFile(inFiles);

                        System.out.println("INSTALLPATH=" + Settings.getInstallPath());
                        System.out.println("SE ENVIA ROBOT:" + HelperEditor.currentRobotPackage + "."
                                + HelperEditor.currentRobotName);

                        // si quiere seleccionar enemigos
                        if (Settings.getProperty("level.default").equals(Language.get("level.four"))) {
                            try {
                                DialogSelectEnemies.getInstance();
                            } catch (NoEnemiesException e2) {
                                new MessageDialog(Language.get("robot.noEnemies"), MessageType.ERROR);
                            }
                            return;
                        } else {
                            callBatalla(null, null);
                        }
                    } else {
                        System.out.println("Error en codigo transformado por AgregadorDeConsola");
                    }
                }
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }

        /** Recibe un archivo conteniendo codigo fuente java, y crea el .class correspondiente
         * @param sourcePath El archivo .java
         * @return Un archivo conteniendo el path al .class generado, o null si no fue posible compilar porque hubo errores en el codigo fuente.
         */
        private Collection<File> createClassFiles(File sourcePath) throws Exception, IOException {
            Collection<File> f = CompileString.compile(sourcePath, basePathRobots);
            if (CompileString.hasError()) {
                int cantErrores = 0;
                for (Diagnostic<?> diag : CompileString.diagnostics) {
                    if (!diag.getKind().equals(Kind.WARNING)) {
                        int line = (int) diag.getLineNumber();
                        int col = (int) diag.getColumnNumber();
                        if (line > 0 && col > 0) {
                            highlightCode(line, col);
                            cantErrores++;
                        }
                    }
                }
                if (cantErrores > 0) {
                    new MessageDialog(Language.get("compile.error"), MessageType.ERROR);
                }
                return null;
            } else {
                return f;
            }
        }

        /* crea un jar con todas las clases del robot. el nombre del jar es el nombre del robot */
        private void createJarFile(Collection<File> inFiles) throws FileNotFoundException, IOException {
            File jarFile = new File(basePathRobots, HelperEditor.currentRobotName + ".jar");
            if (jarFile.exists()) {
                jarFile.delete();
            }
            System.out.println("Path del JAR ==" + jarFile);
            jarFile.createNewFile();
            FileOutputStream fos = new FileOutputStream(jarFile);
            BufferedOutputStream bo = new BufferedOutputStream(fos);

            Manifest manifest = new Manifest();
            manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
            JarOutputStream jarOutput = new JarOutputStream(fos, manifest);
            int basePathLength = basePathRobots.getAbsolutePath().length() + 1; // +1 para incluir al "/" final
            byte[] buf = new byte[1024];
            int anz;
            try {
                // para todas las clases...
                for (File inFile : inFiles) {
                    BufferedInputStream bi = new BufferedInputStream(new FileInputStream(inFile));
                    try {
                        String relative = inFile.getAbsolutePath().substring(basePathLength);
                        // copia y agrega el archivo .class al jar
                        JarEntry je2 = new JarEntry(relative);
                        jarOutput.putNextEntry(je2);
                        while ((anz = bi.read(buf)) != -1) {
                            jarOutput.write(buf, 0, anz);
                        }
                        jarOutput.closeEntry();
                    } finally {
                        try {
                            bi.close();
                        } catch (IOException ignored) {
                        }
                    }
                }
            } finally {
                try {
                    jarOutput.close();
                } catch (IOException ignored) {
                }
                try {
                    fos.close();
                } catch (IOException ignored) {
                }
                try {
                    bo.close();
                } catch (IOException ignored) {
                }
            }
        }
    });
    compileButton.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseEntered(MouseEvent e) {
            e.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        }

        @Override
        public void mouseExited(MouseEvent e) {
            e.getComponent().setCursor(Cursor.getDefaultCursor());
        }
    });

    compileButton.setBounds(MIN_WIDTH, 0, MAX_WIDTH - MIN_WIDTH, BUTTON_HEIGHT);
    compileButton.setFont(smallButtonFont);
    compileButton.setAlignmentX(LEFT_ALIGNMENT);
    compileButton.setText(Language.get("compileButton.title"));
}

From source file:org.eurocarbdb.application.glycoworkbench.plugin.PeakListChartPanel.java

public void onActivateZooming() {
    is_moving = false;
    theChartPanel.setCursor(Cursor.getDefaultCursor());
}

From source file:AltiConsole.AltiConsoleMainScreen.java

public boolean ErasingFlight() {
    this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    if (Serial.getConnected() == false) {
        boolean ret = false;
        ret = ConnectToAlti();/*from ww w  . j  a  va  2s  .co  m*/
        if (!ret) {
            System.out.println("Data retrieval timed out\n");
            this.setCursor(Cursor.getDefaultCursor());
            return false;
        }
    }
    Serial.writeData("e;\n");
    this.setCursor(Cursor.getDefaultCursor());
    return true;
}