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:org.forester.archaeopteryx.TreePanel.java

final private void cutSubtree(final PhylogenyNode node) {
    if (getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED) {
        errorMessageNoCutCopyPasteInUnrootedDisplay();
        return;//from   ww w  .jav  a2  s  . co  m
    }
    if (node.isRoot()) {
        JOptionPane.showMessageDialog(this, "Cannot cut entire tree as subtree", "Attempt to cut entire tree",
                JOptionPane.ERROR_MESSAGE);
        return;
    }
    final String label = getASimpleTextRepresentationOfANode(node);
    final int r = JOptionPane.showConfirmDialog(null, "Cut subtree" + label + "?", "Confirm Cutting of Subtree",
            JOptionPane.YES_NO_OPTION);
    if (r != JOptionPane.OK_OPTION) {
        return;
    }
    setCopiedAndPastedNodes(null);
    setCutOrCopiedTree(_phylogeny.subTree(node));
    _phylogeny.deleteSubtree(node, true);
    _phylogeny.hashIDs();
    _phylogeny.recalculateNumberOfExternalDescendants(true);
    resetNodeIdToDistToLeafMap();
    setEdited(true);
    repaint();
}

From source file:jeplus.gui.JPanel_EPlusProjectFiles.java

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

    // Test if the template file is present
    String fn = (String) cboTemplateFile.getSelectedItem();
    String templfn = RelativeDirUtil.checkAbsolutePath(txtIdfDir.getText() + fn, Project.getBaseDir());
    File ftmpl = new File(templfn);
    if (!ftmpl.exists()) {
        int n = JOptionPane.showConfirmDialog(MainGUI,
                "<html><p><center>The template file " + templfn + " does not exist."
                        + "Do you want to select one?</center></p><p> Select 'NO' to create this file. </p>",
                "Template file not available", JOptionPane.YES_NO_OPTION);
        if (n == JOptionPane.YES_OPTION) {
            this.cmdSelectTemplateFileActionPerformed(null);
            templfn = txtIdfDir.getText() + (String) cboTemplateFile.getSelectedItem();
        }//from ww w . j ava  2  s.c o m
    } else {
        if (ftmpl.length() > 2000000) {
            int n = JOptionPane.showConfirmDialog(MainGUI,
                    "<html><p><center>jEPlus editor does not handle large IDF models well.<br />Open " + templfn
                            + " may slow down your computer considerably.<br />"
                            + "Do you want to continue?<br /> </center></p>",
                    "Template file is too big", JOptionPane.YES_NO_OPTION);
            if (n == JOptionPane.NO_OPTION) {
                return;
            }
        }
    }

    int idx = MainGUI.getTpnEditors().indexOfTab(fn);
    if (idx >= 0) {
        MainGUI.getTpnEditors().setSelectedIndex(idx);
    } else {
        //            EPlusTextPanel TemplFilePanel = new EPlusTextPanel(
        //                    MainGUI.getTpnEditors(),
        //                    fn,
        //                    EPlusTextPanel.EDITOR_MODE,
        //                    EPlusConfig.getFileFilter(EPlusConfig.EPINPUT),
        //                    templfn,
        //                    Project);
        EPlusEditorPanel TemplFilePanel = new EPlusEditorPanel(MainGUI.getTpnEditors(), fn, templfn,
                EPlusEditorPanel.FileType.IDF, Project);
        int ti = MainGUI.getTpnEditors().getTabCount();
        TemplFilePanel.setTabId(ti);
        MainGUI.getTpnEditors().addTab(fn, TemplFilePanel);
        MainGUI.getTpnEditors().setSelectedIndex(ti);
        MainGUI.getTpnEditors().setTabComponentAt(ti,
                new ButtonTabComponent(MainGUI.getTpnEditors(), TemplFilePanel));
        MainGUI.getTpnEditors().setToolTipTextAt(ti, templfn);
    }
}

From source file:com.alvermont.terraj.fracplanet.ui.AbstractTerrainViewerFrame.java

private void saveParamsItemActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_saveParamsItemActionPerformed
{//GEN-HEADEREND:event_saveParamsItemActionPerformed

    final int choice = this.xmlChooser.showSaveDialog(this);

    if (choice == JFileChooser.APPROVE_OPTION) {
        if (!this.xmlChooser.getSelectedFile().isFile() || (JOptionPane.showConfirmDialog(this,
                "This file already exists. Do you want to\n" + "overwrite it?", "Replace File?",
                JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)) {
            try {
                final File target = FileUtils.addExtension(this.xmlChooser.getSelectedFile(), ".xml");

                final XMLEncoder enc = new XMLEncoder(new FileOutputStream(target));

                getParameters().getRenderParameters().setCameraPosition(display.getCameraPosition());
                getParameters().getCameraPositionParameters().setPositions(this.cameraPosDialog.getPositions());

                enc.setPersistenceDelegate(TerrainParameters.ObjectTypeEnum.class,
                        new EnumDelegate<TerrainParameters.ObjectTypeEnum>(
                                TerrainParameters.ObjectTypeEnum.class));

                enc.writeObject(getParameters());

                enc.close();//w w w .  j  av a  2 s.  c  o m
            } catch (IOException ioe) {
                log.error("Error writing xml file", ioe);

                JOptionPane.showMessageDialog(this,
                        "Error: " + ioe.getMessage() + "\nCheck log file for full details", "Error Saving",
                        JOptionPane.ERROR_MESSAGE);
            }
        }
    }
}

From source file:frames.consulta.java

private void btneliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btneliminarActionPerformed
    int filase = tblconsulta.getSelectedRow();

    try {/*from  w w  w  .j  a va 2 s  . co m*/
        String cedula, nombre, ape, edad, direccion;
        if (filase == -1) {
            JOptionPane.showMessageDialog(null, "Debe Seleccionar un Paciente", "Advertencia",
                    JOptionPane.WARNING_MESSAGE);
        } else {

            int valor = JOptionPane.showConfirmDialog(this, "Esta Seguro eliminar el paciente?",
                    "Advertencia", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
            if (valor == JOptionPane.YES_NO_OPTION) {
                JPasswordField pf = new JPasswordField();
                int okCxl = JOptionPane.showConfirmDialog(null, pf, "Enter Password",
                        JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
                if (okCxl == JOptionPane.OK_OPTION) {
                    String password = new String(pf.getPassword());
                    String cap = "", cap1 = "";
                    int id;
                    String encriptado = DigestUtils.md5Hex(password);

                    String sql = "";

                    sql = "SELECT * FROM administrador WHERE clave='" + encriptado + "'";

                    try {
                        Statement st = cn.createStatement();
                        ResultSet rs = st.executeQuery(sql);

                        while (rs.next()) {
                            id = rs.getInt("id_usuario");
                            cap = rs.getString("usuario");
                            cap1 = rs.getString("clave");
                        }

                        if (cap1.equals(encriptado)) {

                            modelo = (DefaultTableModel) tblconsulta.getModel();
                            cedula = tblconsulta.getValueAt(filase, 0).toString();
                            nombre = tblconsulta.getValueAt(filase, 1).toString();
                            ape = tblconsulta.getValueAt(filase, 2).toString();
                            edad = tblconsulta.getValueAt(filase, 3).toString();
                            direccion = tblconsulta.getValueAt(filase, 4).toString();

                            Eliminar(cedula);

                        } else {
                            JOptionPane.showMessageDialog(null, "Clave Invalida", "Advertencia",
                                    JOptionPane.WARNING_MESSAGE);

                        }
                    } catch (SQLException ex) {
                        JOptionPane.showMessageDialog(null, ex);
                        ;
                    }
                    //System.err.println("You entered: " + password);
                }
                //System.exit(0);
            }
        }
    } catch (Exception e) {
        //registro.action = "Ver";
    }
}

From source file:com.alvermont.terraj.stargen.ui.StargenFrame.java

private void saveMenuItemActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_saveMenuItemActionPerformed
{//GEN-HEADEREND:event_saveMenuItemActionPerformed

    final int choice = this.xmlChooser.showSaveDialog(this);

    if (choice == JFileChooser.APPROVE_OPTION) {
        if (!this.xmlChooser.getSelectedFile().exists() || (JOptionPane.showConfirmDialog(this,
                "This file already exists. Do you want to\n" + "overwrite it?", "Replace File?",
                JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)) {
            try {
                final File target = FileUtils.addExtension(this.xmlChooser.getSelectedFile(), ".xml");

                final XMLEncoder enc = new XMLEncoder(new FileOutputStream(target));

                enc.writeObject(this.parameters);

                enc.close();//from  w  w  w  .ja v  a2 s .c om
            } catch (IOException ioe) {
                log.error("Error writing xml file", ioe);

                JOptionPane.showMessageDialog(this,
                        "Error: " + ioe.getMessage() + "\nCheck log file for full details", "Error Saving",
                        JOptionPane.ERROR_MESSAGE);
            }
        }
    }
}

From source file:com.iucosoft.eavertizare.gui.MainJFrame.java

private void sendAvertizare(String tipAvertizare) {
    int selectedRowIndex = jTableClients.getSelectedRow();
    Client client = null;//from  w ww  .  j  a v a 2 s  .c  om
    int contor = 0;
    String mesaj = "";
    Icon icon = new ImageIcon(getClass().getResource("/images/help_and_support.png"));
    if (selectedRowIndex != -1) {

        int rez = JOptionPane.showConfirmDialog(this, "Doriti sa modificati mesajul ?", "Question",
                JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, icon);
        switch (rez) {
        case JOptionPane.YES_OPTION:
            client = cientForIndex(selectedRowIndex);

            sendAvertizareJFrame(client.getFirma(), client, tipAvertizare);
            break;

        case JOptionPane.NO_OPTION:
            client = cientForIndex(selectedRowIndex);
            SimpleDateFormat sdf = new SimpleDateFormat("dd/M/yyyy");
            String mesajClient = client.getFirma().getMesajPentruClienti()
                    .replaceFirst("nume", client.getNume()).replaceFirst("prenume", client.getPrenume())
                    .replaceFirst("data", sdf.format(client.getDateExpirare()).toString())
                    .replaceFirst("compania", client.getFirma().getNumeFirma());
            switch (tipAvertizare) {
            case "SMS AND E-MAIL":
                mesaj = "Sms si e-mail";

            {
                try {

                    client.setTrimis(true);
                    clientsDao.update(client.getFirma(), client);
                    smsSender.sendSms(client.getNrTelefon(), mesajClient);
                    mailSender.sendMail(client.getEmail(), "E-avetizare", mesajClient);
                } catch (Exception ex) {
                    //Logger.getLogger(MainJFrame.class.getName()).log(Level.SEVERE, null, ex);
                    JOptionPane.showMessageDialog(new JFrame(), "Verificai conexiunea la internet!\n" + ex,
                            "Error", JOptionPane.ERROR_MESSAGE);
                    contor = 1;
                }

            }

                clientiTableModel.refreshModel();
                break;
            case "SMS":
                mesaj = "Sms";

                try {
                    smsSender.sendSms(client.getNrTelefon(), mesajClient);
                } catch (Exception ex) {
                    //Logger.getLogger(MainJFrame.class.getName()).log(Level.SEVERE, null, ex);
                    JOptionPane.showMessageDialog(new JFrame(), "Verificai conexiunea la internet!\n" + ex,
                            "Error", JOptionPane.ERROR_MESSAGE);
                    contor = 1;
                }

                break;
            case "E-MAIL":
                mesaj = "E-mail";
                try {
                    mailSender.sendMail(client.getEmail(), "E-avetizare", mesajClient);
                } catch (Exception ex) {
                    //Logger.getLogger(MainJFrame.class.getName()).log(Level.SEVERE, null, ex);
                    JOptionPane.showMessageDialog(new JFrame(), "Verificai conexiunea la internet!\n" + ex,
                            "Error", JOptionPane.ERROR_MESSAGE);
                    contor = 1;
                }

                break;
            }
            if (contor != 1) {
                JOptionPane.showMessageDialog(MainJFrame.this, mesaj + " transmis cu succes!", "Info",
                        JOptionPane.INFORMATION_MESSAGE);
            }

            break;

        case JOptionPane.CLOSED_OPTION:
            break;

        }
    } else {
        JOptionPane.showMessageDialog(this, "Selectati clientul!", "Info", JOptionPane.INFORMATION_MESSAGE);
    }
}

From source file:brainflow.app.toplevel.BrainFlow.java

private void register(IImageSource dataSource) {
    DataSourceManager manager = DataSourceManager.get();
    boolean alreadyRegistered = manager.isRegistered(dataSource);

    try {/*from www .j ava 2s  .  co m*/
        if (alreadyRegistered) {
            long lastModified = dataSource.getDataFile().getContent().getLastModifiedTime();
            long lastRead = dataSource.whenRead();

            if (lastModified > lastRead) {
                StringBuffer sb = new StringBuffer();
                sb.append("Image " + dataSource.getDataFile().getName().getBaseName());
                sb.append(
                        "has already been loaded in BrainFlow, but has changed on disk.  Would you like to reload?");

                Integer ret = JOptionPane.showConfirmDialog(brainFrame, sb.toString(),
                        "Image has been modified", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);

                if (ret == JOptionPane.YES_OPTION) {
                    dataSource.releaseData();
                }
            } else {
                log.info(dataSource.getStem() + " is already registered ...");
            }

        } else {
            manager.register(dataSource);
        }
    } catch (FileSystemException e) {
        JOptionPane.showMessageDialog(brainFrame, "Error accessing file information: " + e.getMessage());
    }

}

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

private void btnguardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnguardarActionPerformed
    // TODO add your handling code here:
    String palabra = "";
    String palabra2 = "";
    if (accion == 1) {
        palabra = "registrar";
        palabra2 = "registrado";

        if (JOptionPane.showConfirmDialog(null, "Desea " + palabra + " el Bien?", "Mensaje del Sistema",
                JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {

            bienControlador.getSeleccionado().setNombre(nombreField.getText().toUpperCase());
            //                bienControlador.getSeleccionado().setCodigo(idField.getText());
            bienControlador.getSeleccionado().setDescripcion(descripcionField.getText().toUpperCase());
            bienControlador.getSeleccionado().setFoto(fotoField.getText());

            //                Clase clase = (Clase) cmbClase.getSelectedItem();
            //                bienControlador.getSeleccionado().setClase(clase);
            bienControlador.accion(accion);
            lista.add(bienControlador.getSeleccionado());

            if (accion == 1) {
                JOptionPane.showMessageDialog(null, "Bien " + palabra2 + " correctamente",
                        "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE);

            } else {
                JOptionPane.showMessageDialog(null, "Bien no " + palabra2, "Mensaje del Sistema",
                        JOptionPane.ERROR_MESSAGE);
            }//www .j a v a2s  . c om
        } else {

            JOptionPane.showMessageDialog(null, "Bien no " + palabra2, "Mensaje del Sistema",
                    JOptionPane.ERROR_MESSAGE);
        }
    } else if (accion == 2) {
        palabra = "modificar";
        palabra2 = "modificado";

        if (JOptionPane.showConfirmDialog(null, "Desea " + palabra + " el Bien?", "Mensaje del Sistema",
                JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {

            if (accion == 2) {
                JOptionPane.showMessageDialog(null, "Bien " + palabra2 + " correctamente",
                        "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE);

                lista.clear();
                bienControlador.getSeleccionado().setNombre(nombreField.getText().toUpperCase());
                //                    bienControlador.getSeleccionado().setCodigo(nombreField.getText());
                bienControlador.getSeleccionado().setDescripcion(descripcionField.getText().toUpperCase());
                bienControlador.getSeleccionado().setFoto(fotoField.getText());

                //                    Clase clase = (Clase) cmbClase.getSelectedItem();
                //                    bienControlador.getSeleccionado().setClase(clase);
                bienControlador.accion(accion);
                listar();

            } else {
                JOptionPane.showMessageDialog(null, "Bien no " + palabra2, "Mensaje del Sistema",
                        JOptionPane.ERROR_MESSAGE);
            }
        } else {
            JOptionPane.showMessageDialog(null, "Bien no " + palabra2, "Mensaje del Sistema",
                    JOptionPane.ERROR_MESSAGE);
        }
    }

    for (DetalleBienCampo detalle : lista3) {
        detalle.setBien(bienControlador.getSeleccionado());
        detalleControlador.setSeleccionado(detalle);
        detalleControlador.accion(Controlador.MODIFICAR);
    }

    lista3.clear();
    FormularioUtil.activarComponente(panelOpciones, true);
    FormularioUtil.activarComponente(panelGuardar, false);
    FormularioUtil.activarComponente(panelDatos, false);
    FormularioUtil.limpiarComponente(panelDatos);
    fotoLbl.setIcon(null);
    descripcionField.setText(null);

}

From source file:userinterface.properties.GUIGraphPicker.java

private void lineOkayButtonActionPerformed(java.awt.event.ActionEvent evt) {

    if (!this.plotType2d.isSelected() && !this.plotType3d.isSelected()) {
        this.plugin.error("Please select a plot type!");
        return;//from  w  w w .  ja v a 2s  . co  m
    }

    // this is for the parametric case, getselecteditem will be null then
    if (selectAxisConstantCombo.getSelectedItem() == null) {

        if (newGraphRadio.isSelected()) {
            /* Make new graph. */
            graphModel2D = new ParametricGraph("");
            graphHandler.addGraph(graphModel2D);

        } else {
            /* Add to an existing graph. */

            if (!(graphHandler
                    .getModel(existingGraphCombo.getSelectedItem().toString()) instanceof ParametricGraph)) {
                graphModel2D = null;
                return;
            }

            graphModel2D = (Graph) graphHandler.getModel(existingGraphCombo.getSelectedItem().toString());
        }

        graphCancelled = false;
        setVisible(false);

        return;
    }

    int numSeries = 1;

    // see which constant is on x axis
    rangerX = selectAxisConstantCombo.getSelectedItem().toString();

    if (this.plotType3d.isSelected()) {

        rangerY = selectYaxisConstantCombo.getSelectedItem().toString();

    }

    // init arrays
    otherValues = new Values();
    multiSeries = new Vector<DefinedConstant>();

    // go through all constants in picker list
    for (int j = 0; j < pickerList.getNumConstants(); j++) {
        // get constant
        DefinedConstant tmpConstant = pickerList.getConstantLine(j).getDC();
        // if its the constant for the x-axis, store info about the constant
        if (tmpConstant.getName().equals(rangerX)) {
            rangingConstantX = tmpConstant;
        }
        // otherwise store info about the selected values
        else {

            if (this.plotType3d.isSelected()) {
                if (tmpConstant.getName().equals(rangerY))
                    continue;
            }

            // Is this constant just a value, or does it have a range?
            Object value = pickerList.getConstantLine(j).getSelectedValue();
            if (value instanceof String) {
                /* Yes, calculate the numSeries. */
                multiSeries.add(pickerList.getConstantLine(j).getDC());
                numSeries *= tmpConstant.getNumSteps();
            } else {
                /* No, just the one. */
                otherValues.addValue(tmpConstant.getName(), value);
            }
        }
    }

    if (this.plotType3d.isSelected()) {

        //go through all constants in the y axis picker list
        for (int j = 0; j < pickerList.getNumConstants(); j++) {

            // get constant
            DefinedConstant tmpConstant = pickerList.getConstantLine(j).getDC();

            if (tmpConstant.getName().equals(rangerY)) {
                rangingConstantY = tmpConstant;
            }
        }

    }

    //sort out which one to add it to
    if (rangingConstantX == null)
        return;

    //if 3d plot is selected and y axis is not selected, select it!
    if (this.plotType3d.isSelected() && rangingConstantY == null)
        return;

    // if there are a lot of series, check if this is what the user really wanted
    if (numSeries > MAX_NUM_SERIES_BEFORE_QUERY) {
        String[] choices = { "Yes", "No" };
        int choice = -1;
        choice = plugin.optionPane(
                "Warning: This will plot " + numSeries + " series.\nAre you sure you want to continue?",
                "Question", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, choices, choices[0]);
        if (choice != 0)
            return;
    }

    if (this.plotType2d.isSelected()) {

        if (newGraphRadio.isSelected()) {
            /* Make new graph. */
            //graphModel = new Graph();
            graphModel2D = new ParametricGraph("");
            graphHandler.addGraph(graphModel2D);

            graphModel2D.getYAxisSettings().setHeading(resultsCollection.getResultName());
            graphModel2D.getXAxisSettings().setHeading(rangerX);
        } else {
            /* Add to an existing graph. */

            graphModel2D = (Graph) graphHandler.getModel(existingGraphCombo.getSelectedItem().toString());
            if (!rangerX.equals(graphModel2D.getXAxisSettings().getHeading())) //FIXME: must do this better in future
                if (!roughExists(rangerX, graphModel2D.getXAxisSettings().getHeading()))
                    graphModel2D.getXAxisSettings()
                            .setHeading(graphModel2D.getXAxisSettings().getHeading() + ", " + rangerX);
        }

    } else if (this.plotType3d.isSelected()) {

        // always the new graph radio button will be selected since we can't have another 3d plot on the same plot

        if (selectAxisConstantCombo.getSelectedItem().toString()
                .equals(selectYaxisConstantCombo.getSelectedItem().toString())) {

            plugin.error("Please select diffrent variables for x and y axis!");
            return;

        }

        graphModel3D = new Graph3D();
        graphHandler.addGraph(graphModel3D);

    }

    graphCancelled = false;
    setVisible(false);
}

From source file:Forms.frm_Penghuni.java

private void btnHapusActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnHapusActionPerformed
    // TODO add your handling code here:
    if ((tblPenghuni.getSelectedRow() == -1)) {
        JOptionPane.showMessageDialog(null, "Silahkan pilih baris yang ingin dihapus pada Tabel..");
    } else {/*from   w  w w .  j  a  v  a  2 s .  c o  m*/
        int pilihan = JOptionPane.showConfirmDialog(this, "Apakah Anda Ingin Menghapus data? ", "Konfirmasi",
                JOptionPane.YES_NO_OPTION);
        if (pilihan == 0) {
            int baris = tblPenghuni.getSelectedRow();
            String id = tblPenghuni.getValueAt(baris, 0).toString();

            if (HapusData(id)) {
                JOptionPane.showMessageDialog(null, "Berhasil Hapus Data");
            } else {
                JOptionPane.showConfirmDialog(null, "Gagal Hapus Data");

            }
            InitTable();
            TampilDataPenghuni();
            bersihkanfield();
            KunciField(false);
        }
    }
}