Example usage for javax.swing JOptionPane YES_NO_OPTION

List of usage examples for javax.swing JOptionPane YES_NO_OPTION

Introduction

In this page you can find the example usage for javax.swing JOptionPane YES_NO_OPTION.

Prototype

int YES_NO_OPTION

To view the source code for javax.swing JOptionPane YES_NO_OPTION.

Click Source Link

Document

Type used for showConfirmDialog.

Usage

From source file:edu.ku.brc.af.ui.forms.IconViewObj.java

/**
 * /*w w  w  .  j a  va  2s .c  o m*/
 */
protected void doDelete() {
    FormDataObjIFace dataObj = iconTray.getSelection();
    if (dataObj != null) {
        Object[] delBtnLabels = { getResourceString("Delete"), getResourceString("CANCEL") };
        int rv = JOptionPane.showOptionDialog(UIRegistry.getTopWindow(),
                UIRegistry.getLocalizedMessage("ASK_DELETE", dataObj.getIdentityTitle()),
                getResourceString("Delete"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null,
                delBtnLabels, delBtnLabels[1]);
        if (rv == JOptionPane.YES_OPTION) {

            iconTray.removeItem(dataObj);
            parentDataObj.removeReference(dataObj, IconViewObj.this.cellName);
            if (mvParent != null) {
                MultiView topLvl = mvParent.getTopLevel();
                topLvl.addDeletedItem(dataObj);
                rootHasChanged();
            }
            iconTray.repaint();
            updateEnableUI();

            rootHasChanged();
        }
    }
}

From source file:fi.hoski.remote.ui.Admin.java

private JMenuItem menuItemRemoveYear() {
    final String title = TextUtil.getText("REMOVE YEAR");
    JMenuItem removeEntityItem = new JMenuItem(title);
    ActionListener removeEntityAction = new ActionListener() {

        @Override/*from  w w  w . ja  va  2  s . c  o  m*/
        public void actionPerformed(ActionEvent e) {
            Object yearString = JOptionPane.showInputDialog(frame, title, "", JOptionPane.OK_CANCEL_OPTION);
            if (yearString != null) {
                String confirm = TextUtil.getText("CONFIRM REMOVE") + " " + yearString;
                if (JOptionPane.showConfirmDialog(frame, confirm, "",
                        JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
                    long year = Long.parseLong(yearString.toString());
                    Day now = new Day();
                    if (year < now.getYear()) {
                        int count = dss.remove(year);
                        JOptionPane.showMessageDialog(frame, TextUtil.getText("REMOVED") + " " + count);
                    } else {
                        JOptionPane.showMessageDialog(frame, TextUtil.getText("CANNOT REMOVE") + " " + year);
                    }
                }
            }
        }
    };
    removeEntityAction = createActionListener(frame, removeEntityAction);
    removeEntityItem.addActionListener(removeEntityAction);
    return removeEntityItem;
}

From source file:com.sec.ose.osi.thread.ui_related.UserCommandExecutionThread.java

private void syncToServer() {
    long start = System.currentTimeMillis();

    boolean result = IdentifyQueue.getInstance().makeBackup();
    if (result == false) {
        mObserver.setResult(UIResponseObserver.RESULT_FAIL);
        mObserver.setFailMessage("Can't make backup file");
        return;/*from   w  w  w.  j av a2 s . com*/
    }

    Property.getInstance().setProperty(Property.IDENTIFICATION_WITH_SYNCHRONOUS_BOM_REFRESH, "false");
    while (IdentifyQueue.getInstance().size() > 0) {

        if (IdentifyQueue.getInstance().size() <= 1) {
            Property.getInstance().setProperty(Property.IDENTIFICATION_WITH_SYNCHRONOUS_BOM_REFRESH, "true");
        } else {
            Property.getInstance().setProperty(Property.IDENTIFICATION_WITH_SYNCHRONOUS_BOM_REFRESH, "false");
        }

        try {
            Thread.sleep(50);
        } catch (Exception e) {
        }

        mObserver.setMessageHeader("Flushing items in identify queue to Protex Server - "
                + IdentifyQueue.getInstance().size() + " file(s) remains.\n");

        IdentifyData iData = IdentifyQueue.getInstance().firstElement();
        if (iData == null)
            break;

        String fullPathMessage = iData.getFilePath().toString();
        String displayedFullPath = "";
        while (fullPathMessage.length() > 75) {
            displayedFullPath += fullPathMessage.substring(0, 75) + "\n        ";
            fullPathMessage = fullPathMessage.substring(75);
        }
        displayedFullPath += fullPathMessage;

        String out = " > Identifying \"" + iData.getProjectName() + "\"\n" + "        " + displayedFullPath
                + "\n " + "        (identified at " + iData.getTimeStamp() + ")";
        mObserver.pushMessageWithHeader(out);
    }
    Property.getInstance().setProperty(Property.IDENTIFICATION_WITH_SYNCHRONOUS_BOM_REFRESH, "true");

    String title = "Sync to server - " + IdentifyMediator.getInstance().getSelectedProjectName();
    String message = "\"Sync To Server\" finished.\n"
            + "Do you want to progress \"Sync From Server\" for UI updating?";
    int yesNo = JOptionPane.showConfirmDialog(null, message, title, JOptionPane.YES_NO_OPTION);

    if (yesNo == JOptionPane.YES_OPTION) {
        long end = System.currentTimeMillis();
        log.debug("@@@     To Server TIME : " + (end - start) / 1000.0);
        syncFromServer();
    }

}

From source file:serial.ChartFromSerial.java

private boolean attemptConnection(String desiredPort, int baudRate) {
    //Port Setup/*  w w  w . ja va2  s. c o  m*/
    chosenPort = SerialPort.getCommPort(desiredPort);
    chosenPort.setComPortTimeouts(SerialPort.TIMEOUT_SCANNER, 0, 0);
    chosenPort.setBaudRate(baudRate);
    //Making sure all goes well
    chosenPort.openPort();
    if (chosenPort.openPort()) {
        createSerialThread(chosenPort);
        buttonsConnected();
        //            buttonsConnected();
        //            if (createSerialThread(chosenPort)){
        //                buttonsConnected();
        //            } else {
        //                JOptionPane.showMessageDialog(rootPane, "Failed to create a serial connection.", "Serial connection failed.", JOptionPane.ERROR_MESSAGE);
        //                chosenPort.closePort();
        //            }
    } else {
        //Prompt user for response
        if (JOptionPane.showConfirmDialog(rootPane,
                "Error at " + portList_jCombo.getSelectedItem().toString() + "\nWould you like to refresh?",
                "Trouble connecting to " + portList_jCombo.getSelectedItem().toString(),
                JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE) == JOptionPane.YES_OPTION) {
            hardRefresh();
        } else {
            buttonsOff();
        }
    }
    return false;
}

From source file:com.proyecto.vista.MantenimientoFactura.java

private void btneliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btneliminarActionPerformed
    // TODO add your handling code here:
    accion = Controlador.ELIMINAR;/*  ww w.j a va  2 s.  co m*/
    if (tblFactura.getSelectedRow() != -1) {

        Integer codigo = tblFactura.getSelectedRow();

        Factura factura = facturaControlador.buscarPorId(lista.get(codigo).getId());

        if (factura != null) {
            if (JOptionPane.showConfirmDialog(null, "Desea Eliminar el Tipo?", "Mensaje del Sistema",
                    JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {

                int[] filas = tblFactura.getSelectedRows();
                for (int i = 0; i < filas.length; i++) {
                    Factura factura2 = lista.get(filas[0]);
                    lista.remove(factura2);
                    facturaControlador.setSeleccionado(factura2);
                    facturaControlador.accion(accion);
                }
                if (facturaControlador.accion(accion) == 3) {
                    JOptionPane.showMessageDialog(null, "Tipo eliminado correctamente", "Mensaje del Sistema",
                            JOptionPane.INFORMATION_MESSAGE);

                } else {
                    JOptionPane.showMessageDialog(null, "Tipo no eliminada", "Mensaje del Sistema",
                            JOptionPane.ERROR_MESSAGE);
                }
            } else {
                JOptionPane.showMessageDialog(null, "Tipo no eliminada", "Mensaje del Sistema",
                        JOptionPane.ERROR_MESSAGE);
            }
        }
    } else {
        JOptionPane.showMessageDialog(null, "Debe seleccionar un Tipo", "Mensaje del Sistema",
                JOptionPane.ERROR_MESSAGE);
    }
}

From source file:canreg.client.gui.management.CanReg4MigrationInternalFrame.java

@Action
public void MigrationAction() {
    okButton.setEnabled(false);/*from w  w  w. j av a 2 s.c  o m*/
    doneButton.setEnabled(false);
    cancelButton.setEnabled(true);
    jList1.setEnabled(false);
    EditDatabaseVariableTableAssociationInternalFrame edvif = new EditDatabaseVariableTableAssociationInternalFrame();
    int addServer = JOptionPane.showInternalConfirmDialog(
            CanRegClientApp.getApplication().getMainFrame().getContentPane(),
            java.util.ResourceBundle
                    .getBundle("canreg/client/gui/management/resources/CanReg4SystemConverterInternalFrame")
                    .getString("SUCCESSFULLY_CREATED_XML: ") + "\'" + Globals.CANREG_SERVER_SYSTEM_CONFIG_FOLDER
                    + Globals.FILE_SEPARATOR + regcode + "\'.\n"
                    + java.util.ResourceBundle.getBundle(
                            "canreg/client/gui/management/resources/CanReg4SystemConverterInternalFrame")
                            .getString("ADD_IT_TO_FAV_SERVERS?"),
            "Success", JOptionPane.YES_NO_OPTION);
    if (addServer == JOptionPane.YES_OPTION) {
        localSettings = CanRegClientApp.getApplication().getLocalSettings();
        localSettings.addServerToServerList(dlm.get(list.getSelectedIndex()), "localhost", Globals.DEFAULT_PORT,
                regcode);
        localSettings.writeSettings();
    }
    try {
        edvif.setTitle("Variables and Tables for "
                + WordUtils.capitalize(dlm.get(list.getSelectedIndex()).toLowerCase()));
        edvif.loadSystemDefinition(
                Globals.CANREG_SERVER_SYSTEM_CONFIG_FOLDER + Globals.FILE_SEPARATOR + regcode + ".xml");
        edvif.setDesktopPane(desktopPane);
        CanRegClientView.showAndPositionInternalFrame(desktopPane, edvif);
    } catch (IOException ex) {
        Logger.getLogger(CanReg4SystemConverterInternalFrame.class.getName()).log(Level.SEVERE, null, ex);
    } catch (ParserConfigurationException ex) {
        Logger.getLogger(CanReg4SystemConverterInternalFrame.class.getName()).log(Level.SEVERE, null, ex);
    } catch (SAXException ex) {
        Logger.getLogger(CanReg4SystemConverterInternalFrame.class.getName()).log(Level.SEVERE, null, ex);
    }

    edvif.saveButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //logout from canreg system before conversion
            if (CanRegClientApp.getApplication().loggedIn) {
                try {
                    CanRegClientApp.getApplication().logOut();
                } catch (RemoteException ex) {
                    Logger.getLogger(CanReg4MigrationInternalFrame.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
            //check to see if there is a database already - rename it
            File databaseFolder = new File(
                    Globals.CANREG_SERVER_DATABASE_FOLDER + Globals.FILE_SEPARATOR + regcode);
            if (databaseFolder.exists()) {
                int i = 0;
                File folder2 = databaseFolder;
                while (folder2.exists()) {
                    i++;
                    folder2 = new File(
                            Globals.CANREG_SERVER_DATABASE_FOLDER + Globals.FILE_SEPARATOR + regcode + i);
                }
                databaseFolder.renameTo(folder2);
                debugOut("database: " + databaseFolder);
                try {
                    canreg.common.Tools.fileCopy(
                            Globals.CANREG_SERVER_SYSTEM_CONFIG_FOLDER + Globals.FILE_SEPARATOR + regcode
                                    + ".xml",
                            Globals.CANREG_SERVER_SYSTEM_CONFIG_FOLDER + Globals.FILE_SEPARATOR + regcode + i
                                    + ".xml");
                } catch (IOException ex) {
                    Logger.getLogger(CanReg4MigrationInternalFrame.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
            ProgressBar.setStringPainted(true);
            cTask = new ProgressTask(
                    org.jdesktop.application.Application.getInstance(canreg.client.CanRegClientApp.class));
            cTask.execute();
            cTask.addPropertyChangeListener(new PropertyChangeListener() {
                @Override
                public void propertyChange(PropertyChangeEvent evt) {
                    if ("progress".equals(evt.getPropertyName())) {
                        ProgressBar.setValue((Integer) evt.getNewValue());
                        ProgressBar.setString(evt.getNewValue().toString() + "%");
                    }
                }
            });
        }
    });
}

From source file:com.sshtools.sshterm.SshTermSessionPanel.java

/**
 *
 *
 * @return//ww w  .j a va 2 s  .  c o m
 */
public boolean canClose() {
    if ((session != null) && session.isOpen()) {
        setFullScreenMode(false);

        if (JOptionPane.showConfirmDialog(this, "Close the current session?", "Close Session",
                JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.NO_OPTION) {
            return false;
        }
    }

    return true;
}

From source file:com.proyecto.vista.MantenimientoClase.java

private void btneliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btneliminarActionPerformed
    // TODO add your handling code here:
    accion = Controlador.ELIMINAR;//  ww w  .j a  v a  2s  .  c  o  m
    if (tblclase.getSelectedRow() != -1) {

        Integer id = tblclase.getSelectedRow();

        //            Clase clase = claseControlador.buscarPorId(lista.get(id).getId());

        if (tblclase.getSelectedRow() != -1) {
            if (JOptionPane.showConfirmDialog(null, "Desea Eliminar la Clase?", "Mensaje del Sistema",
                    JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {

                //                    int[] filas = tblclase.getSelectedRows();
                //                    for (int i = 0; i < filas.length; i++) {
                //                        Clase clase2 = lista.get(filas[0]);
                claseControlador.setSeleccionado(lista.get(id));
                lista.remove(lista.get(id));
                claseControlador.accion(accion);
                //                    }
                if (claseControlador.accion(accion) == 3) {
                    JOptionPane.showMessageDialog(null, "Clase eliminada correctamente", "Mensaje del Sistema",
                            JOptionPane.INFORMATION_MESSAGE);

                } else {
                    JOptionPane.showMessageDialog(null, "Clase no eliminada", "Mensaje del Sistema",
                            JOptionPane.ERROR_MESSAGE);
                }
            } else {
                JOptionPane.showMessageDialog(null, "Clase no eliminada", "Mensaje del Sistema",
                        JOptionPane.ERROR_MESSAGE);
            }
        }
    } else {
        JOptionPane.showMessageDialog(null, "Debe seleccionar una clase", "Mensaje del Sistema",
                JOptionPane.ERROR_MESSAGE);
    }
}

From source file:org.csa.rstb.polarimetric.rcp.toolviews.HaAlphaPlotPanel.java

@Override
protected boolean checkDataToClipboardCopy() {
    final int warnLimit = 2000;
    final int excelLimit = 65536;
    final int numNonEmptyBins = getNumNonEmptyBins();
    if (numNonEmptyBins > warnLimit) {
        String excelNote = "";
        if (numNonEmptyBins > excelLimit - 100) {
            excelNote = "Note that e.g., Microsoft Excel 2002 only supports a total of " + excelLimit
                    + " rows in a sheet.\n";
        }/*  ww w . ja  va  2  s.co  m*/
        final String message = MessageFormat.format("This scatter plot contains {0} non-empty bins.\n"
                + "For each bin, a text data row containing an x, y and z value will be created.\n"
                + "{1}\nPress ''Yes'' if you really want to copy this amount of data to the system clipboard.\n",
                numNonEmptyBins, excelNote);
        final int status = JOptionPane.showConfirmDialog(this, message, "Copy Data to Clipboard",
                JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
        if (status != JOptionPane.YES_OPTION) {
            return false;
        }
    }
    return true;
}

From source file:UserInterface.FinanceRole.TransferToRegSiteJPanel.java

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

    //Validation//from  w ww .j av a2s.  co  m
    boolean validationSuccess;
    validationSuccess = validationIndividualTansfer();

    if (validationSuccess) {

        RegisteredSiteEnterprise objRegisteredSiteEnterprise = null;

        int selectedRegSite = regSiteJTable.getSelectedRow();

        if (selectedRegSite < 0) {
            JOptionPane.showMessageDialog(null, "Please select a Site");
            return;
        }

        objRegisteredSiteEnterprise = (RegisteredSiteEnterprise) regSiteJTable.getValueAt(selectedRegSite, 1);

        if (objRegisteredSiteEnterprise != null) {

            objWorldEnterprise.getObjTransactionDirectory().updateTransactionAccount();

            BigDecimal worldBalance = objWorldEnterprise.getObjTransactionDirectory().getAvailableRealBalance();

            int positiveWorldBalance = worldBalance.compareTo(individualDonationAmount);

            if (positiveWorldBalance >= 1) {

                int response = JOptionPane.showConfirmDialog(null,
                        "Total transfer of $ " + individualDonationAmount + "/- Do you want to transfer?",
                        "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
                if (response == JOptionPane.YES_OPTION) {

                    //Registered Site Transaction
                    Transaction objRealRSTransaction = (Transaction) objRegisteredSiteEnterprise
                            .getObjTransactionDirectory().addNewTransaction();
                    objRealRSTransaction.setTransactionBDAmount(individualDonationAmount);
                    objRealRSTransaction.setObjUserAccountSource(objUserAccount);
                    objRealRSTransaction.setObjUserAccountDestination(null);
                    objRealRSTransaction.setTransactionSource(
                            Transaction.TransactionSourceType.FromWorldEnterprise.getValue());
                    objRealRSTransaction.setTransactionDestination(
                            Transaction.TransactionSourceType.ToRegSiteEnterprise.getValue());
                    objRealRSTransaction.setTransactionType(Transaction.TransactionType.Credit.getValue());
                    objRealRSTransaction.setTransactionMode(Transaction.TransactionModeType.Real.getValue());
                    objRegisteredSiteEnterprise.getObjTransactionDirectory().updateTransactionAccount();

                    //WorldEnterprise Transaction
                    Transaction objRealWETransaction = (Transaction) objWorldEnterprise
                            .getObjTransactionDirectory().addNewTransaction();
                    objRealWETransaction.setTransactionBDAmount(individualDonationAmount);
                    objRealWETransaction.setObjUserAccountSource(objUserAccount);
                    objRealWETransaction.setObjUserAccountDestination(null);
                    objRealWETransaction.setTransactionSource(
                            Transaction.TransactionSourceType.FromWorldEnterprise.getValue());
                    objRealWETransaction.setTransactionDestination(
                            Transaction.TransactionSourceType.ToRegSiteEnterprise.getValue());
                    objRealWETransaction.setTransactionType(Transaction.TransactionType.Debit.getValue());
                    objRealWETransaction.setTransactionMode(Transaction.TransactionModeType.Real.getValue());
                    objWorldEnterprise.getObjTransactionDirectory().updateTransactionAccount();

                    populateTransactionTable(objRegisteredSiteEnterprise);

                    JOptionPane.showMessageDialog(null,
                            "$ " + individualDonationAmount + "/- transferred successfully");

                    donationAmountJTextField.setText(null);
                    populateLowRegSiteTable();

                    //RegSiteTransferRecords
                    String donationLogs = objRealWETransaction.getTransactionID() + ","
                            + objRealWETransaction.getTransactionBDAmount() + ","
                            + objRealWETransaction.getObjUserAccountSource() + ","
                            + objRealWETransaction.getTransactionSource() + "," + objRegisteredSiteEnterprise
                            + "," + objRealWETransaction.getTransactionDestination() + ","
                            + objRealWETransaction.getTransactionType() + ","
                            + objRealWETransaction.getTransactionMode();

                    GenerateReports.regSiteTransferRecords(donationLogs);
                }

            } else {
                JOptionPane.showMessageDialog(null, "World Balance is low");
            }
        } else {
            JOptionPane.showMessageDialog(null, "Please select again");
        }
    }
}