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:com.net2plan.gui.tools.GUINetworkDesign.java

private void resetButton() {
    try {/*w w w .jav  a  2s. co m*/
        final int result = JOptionPane.showConfirmDialog(null,
                "Are you sure you want to reset? This will remove all unsaved data", "Reset",
                JOptionPane.YES_NO_OPTION);
        if (result != JOptionPane.YES_OPTION)
            return;

        if (inOnlineSimulationMode()) {
            switch (onlineSimulationPane.getSimKernel().getSimCore().getSimulationState()) {
            case NOT_STARTED:
            case STOPPED:
                break;
            default:
                onlineSimulationPane.getSimKernel().getSimCore().setSimulationState(SimState.STOPPED);
                break;
            }
            onlineSimulationPane.getSimKernel().reset();
            setCurrentNetPlanDoNotUpdateVisualization(onlineSimulationPane.getSimKernel().getCurrentNetPlan());
        } else {
            setCurrentNetPlanDoNotUpdateVisualization(new NetPlan());
            //algorithmSelector.reset();
            executionPane.reset();
        }
        //            reportSelector.reset();
        //            reportContainer.removeAll();
    } catch (Throwable ex) {
        ErrorHandling.addErrorOrException(ex, GUINetworkDesign.class);
        ErrorHandling.showErrorDialog("Unable to reset");
    }
    Pair<BidiMap<NetworkLayer, Integer>, Map<NetworkLayer, Boolean>> res = VisualizationState
            .generateCanvasDefaultVisualizationLayerInfo(getDesign());
    vs.setCanvasLayerVisibilityAndOrder(getDesign(), res.getFirst(), res.getSecond());
    updateVisualizationAfterNewTopology();
    undoRedoManager.addNetPlanChange();
}

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

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

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

    try {// www . j a v a2s.c o m
        if (choice == JFileChooser.APPROVE_OPTION) {
            if (!this.pngChooser.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)) {
                List<BufferedImage> images = UIUtils.getPlanetImages(this.planets);

                BufferedImage collage = UIUtils.combineImagesHorizontal(images);

                final File target = FileUtils.addExtension(this.pngChooser.getSelectedFile(), ".png");

                ImageIO.write(collage, PNGFileFilter.getFormatName(target), target);
            }
        }
    } catch (IOException ioe) {
        log.error("Error writing image file", ioe);

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

}

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

private void btnguardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnguardarActionPerformed
    // TODO add your handling code here:
    List<Integer> array = new ArrayList();
    array.add(FormularioUtil.Validar(FormularioUtil.TipoValidacion.NUMERO, this.nombreField, "Nombre"));
    FormularioUtil.validar2(array);//  w ww  .j a  v a 2s  .c  o m

    if (FormularioUtil.error) {
        JOptionPane.showMessageDialog(null, FormularioUtil.mensaje, "Mensaje del Sistema",
                JOptionPane.ERROR_MESSAGE);
        FormularioUtil.mensaje = "";
        FormularioUtil.error = false;
    } else {
        String palabra = "";
        String palabra2 = "";
        if (accion == 1) {
            palabra = "registrar";
            palabra2 = "registrado";

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

                areaControlador.getSeleccionado().setNombre(nombreField.getText().toUpperCase());

                areaControlador.accion(accion);
                lista.add(areaControlador.getSeleccionado());

                if (accion == 1) {
                    JOptionPane.showMessageDialog(null, "Area " + palabra2 + " correctamente",
                            "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE);
                    FormularioUtil.limpiarComponente(panelDatos);
                } else {
                    JOptionPane.showMessageDialog(null, "Area no " + palabra2, "Mensaje del Sistema",
                            JOptionPane.ERROR_MESSAGE);
                }
            } else {
                FormularioUtil.limpiarComponente(panelDatos);
                JOptionPane.showMessageDialog(null, "Area no " + palabra2, "Mensaje del Sistema",
                        JOptionPane.ERROR_MESSAGE);
            }
        } else if (accion == 2) {
            palabra = "modificar";
            palabra2 = "modificado";

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

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

                    lista.clear();
                    areaControlador.getSeleccionado().setNombre(nombreField.getText().toUpperCase());
                    areaControlador.accion(accion);
                    listar();

                    FormularioUtil.limpiarComponente(panelDatos);

                } else {
                    JOptionPane.showMessageDialog(null, "Area no " + palabra2, "Mensaje del Sistema",
                            JOptionPane.ERROR_MESSAGE);
                }
            } else {
                FormularioUtil.limpiarComponente(panelDatos);
                JOptionPane.showMessageDialog(null, "Area no " + palabra2, "Mensaje del Sistema",
                        JOptionPane.ERROR_MESSAGE);
            }
        }

        FormularioUtil.activarComponente(panelOpciones, true);
        FormularioUtil.activarComponente(panelGuardar, false);
        FormularioUtil.activarComponente(panelDatos, false);
    }
}

From source file:com.tiempometa.muestradatos.JProgramTags.java

@Override
public void handleReadings(List<TagReading> readings) {
    bibLabel.setText("");
    if (readings.size() > 0) {
        if (readings.size() == 1) {
            statusLabel.setBackground(Color.cyan);
            statusLabel.setText("Leyendo tag");
            for (TagReading tagReading : readings) {
                logger.info("Tag data dump");
                logger.info(tagReading.getTagReadData().getTag().epcString());
                logger.info(String.valueOf(tagReading.getTagReadData().getData().length));
                logger.info(Hex.encodeHexString(tagReading.getTagReadData().getData()));
                logger.info(String.valueOf(tagReading.getTagReadData().getEPCMemData().length));
                logger.info(Hex.encodeHexString(tagReading.getTagReadData().getEPCMemData()));
                logger.info(String.valueOf(tagReading.getTagReadData().getTIDMemData().length));
                logger.info(Hex.encodeHexString(tagReading.getTagReadData().getTIDMemData()));
                logger.info(String.valueOf(tagReading.getTagReadData().getReservedMemData().length));
                logger.info(Hex.encodeHexString(tagReading.getTagReadData().getReservedMemData()));
                logger.info(String.valueOf(tagReading.getTagReadData().getUserMemData().length));
                logger.info(Hex.encodeHexString(tagReading.getTagReadData().getUserMemData()));
                if (tagReading.getTid() == null) {
                    try {
                        tagReading.setTid(ReaderContext.readTid(tagReading.getEpc(), 12));
                        if (logger.isDebugEnabled()) {
                            logger.debug("Got tag " + tagReading.getEpc() + " - " + tagReading.getTid());
                        }// ww w.  j  a v a2  s . c o  m
                        // try {
                        statusLabel.setBackground(Color.green);
                        statusLabel.setText("Tag leido");
                        tidTextField.setText(tagReading.getTid().toLowerCase());
                        epcTextField.setText(tagReading.getEpc().toLowerCase());
                        programmedEpcTextField.setText("");
                        // find tag by EPC/TID in database
                        logger.debug("Looking up rfid by epc " + tagReading.getEpc() + " epc char "
                                + Hex.encodeHexString(tagReading.getEpc().getBytes()));
                        Rfid rfid = totalRfidMap.get(tagReading.getEpc().toUpperCase());
                        if (rfid == null) {
                            logger.debug("Rfid string not in database tag list. Programming tag.");
                            // if in DB, warn

                            // if not then program with next chipnumber
                            programTag(tagReading);

                        } else {
                            logger.debug("Rfid string IN database tag list.");
                            Rfid batchRfid = rfidMap.get(tagReading.getEpc());
                            if (batchRfid == null) {
                                logger.debug("Rfid string IN current program batch");
                                int response = JOptionPane.showConfirmDialog(this,
                                        "Este tag tiene un cdigo que existe en el evento actual.\n"
                                                + "Corresponde al nmero " + rfid.getBib()
                                                + "\nDesea sobreescribir este tag?",
                                        "Tag ya programado", JOptionPane.YES_NO_OPTION,
                                        JOptionPane.WARNING_MESSAGE);
                                if (response == JOptionPane.YES_OPTION) {
                                    programTag(tagReading);
                                }
                            } else {
                                JOptionPane.showMessageDialog(this,
                                        "Este tag tiene un cdigo que ya ha sido programado en este lote.",
                                        "Tag ya programado", JOptionPane.ERROR_MESSAGE);
                            }
                        }

                        try {
                            Thread.sleep(1000);
                        } catch (InterruptedException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                        statusLabel.setBackground(Color.white);
                        statusLabel.setText("Remover tag");
                        try {
                            Thread.sleep(500);
                        } catch (InterruptedException e1) {
                            e1.printStackTrace();
                        }
                    } catch (ReaderException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                        statusLabel.setBackground(Color.red);
                        statusLabel.setText("Error");
                        try {
                            Thread.sleep(500);
                        } catch (InterruptedException e1) {
                            e1.printStackTrace();
                        }
                    }
                }
            }
        } else {
            statusLabel.setBackground(Color.orange);
            statusLabel.setText("Dos o ms tags");
        }
    } else {
        statusLabel.setBackground(Color.yellow);
        statusLabel.setText("Sin tag");

    }

}

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

/**
 * Opens a file chooser and gives the user an opportunity to save the chart
 * in PNG format.//from w  w w . ja  v  a  2 s . com
 *
 * @throws IOException if there is an I/O error.
 */
@Override
public void doSaveAs() throws IOException {

    JFileChooser fileChooser = new JFileChooser();
    String currentDirectory = System.getProperty(StaticValues.SYSTEM_SAVE_PATH_LABEL);
    if (currentDirectory != null) {
        File savePath = new File(currentDirectory);
        if (savePath.exists() && savePath.isDirectory()) {
            fileChooser.setCurrentDirectory(savePath);
        }
    }
    ExtensionFileFilter pngFilter = new ExtensionFileFilter("PNG_Image_Files", ".png");
    ExtensionFileFilter jpgFilter = new ExtensionFileFilter("JPG_Image_Files", ".jpg");
    fileChooser.addChoosableFileFilter(pngFilter);
    fileChooser.addChoosableFileFilter(jpgFilter);

    int option = fileChooser.showSaveDialog(this);
    if (option == JFileChooser.APPROVE_OPTION) {
        String filename = fileChooser.getSelectedFile().getPath();
        String selectedDescription = fileChooser.getFileFilter().getDescription();
        String fileExtension = StaticValues.DEFAULT_IMAGE_FILE_EXTENSION;
        if (selectedDescription.toLowerCase().contains("png")) {
            fileExtension = "png";
            if (!filename.toLowerCase().endsWith(".png")) {
                filename = filename + ".png";
            }
        } else if (selectedDescription.toLowerCase().contains("jpg")) {
            fileExtension = "jpg";
            if (!filename.toLowerCase().endsWith(".jpg")) {
                filename = filename + ".jpg";
            }
        }
        File selectedFile = new File(filename);
        int confirm = JOptionPane.YES_OPTION;
        if (selectedFile.exists()) {
            confirm = JOptionPane.showConfirmDialog(this, selectedFile.getName() + " exists, overwrite?",
                    "Confirm Overwriting", JOptionPane.YES_NO_OPTION);
        }
        if (confirm == JOptionPane.YES_OPTION) {
            saveTo(filename, fileExtension);
            System.setProperty(StaticValues.SYSTEM_SAVE_PATH_LABEL, fileChooser.getSelectedFile().getParent());
        }
    }
}

From source file:fs.MainWindow.java

public void ExecuteFeatureSelection(int selector) throws IOException {
    String penalization_type = (String) jCB_PenalizationSE.getSelectedItem();
    float alpha = ((Double) jS_AlphaSE.getValue()).floatValue();
    float q_entropy = ((Double) jS_QEntropySE.getValue()).floatValue();
    float beta = ((float) jSliderBetaSE.getValue() / 100);

    //if selected criterion function is CoD, q_entropy = 0
    if (jCB_CriterionFunctionSE.getSelectedIndex() == 1) {
        q_entropy = 0;//from  w w w  .ja va  2s  . c o m
    } //CoD

    if (q_entropy < 0 || alpha < 0) {
        //entrada de dados invalida.
        JOptionPane.showMessageDialog(this,
                "Error on parameter value:The" + " values of q-entropy and Alpha must be positives.",
                "Application Error", JOptionPane.ERROR_MESSAGE);
        return;
    }

    jTA_SaidaSE.setText("");
    jTA_SelectedFeaturesSE.setText("");

    // n = quantidade de valores assumidos pelas caracteristicas.
    int n = Main.maximumValue(Md, 0, lines - 1, 0, columns - 2) + 1;

    //c = numero de rotulos possiveis para as classes.
    int c = Main.maximumValue(Md, 0, lines - 1, columns - 1, columns - 1) + 1;

    jProgressBarSE.setValue(5);
    Thread.yield();

    char[][] strainingset = MathRoutines.float2char(Md);
    char[][] stestset = null;

    if (!jTF_InputTestSE.getText().equals("")) {
        stestset = IOFile.readMatrix(jTF_InputTestSE.getText(), delimiter);
    } else {
        stestset = MathRoutines.float2char(Md);
    }

    int resultsetsize = 1;
    try {
        //vetor com os resultados da selecao de caracteristica.
        resultsetsize = (Integer) jS_MaxResultListSE.getValue();
        if (resultsetsize < 1) {
            Thread.yield();
            JOptionPane
                    .showMessageDialog(this,
                            "Error on parameter value:" + " The Size of the Result List must be a integer value"
                                    + " greater or equal to 1.",
                            "Application Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
    } catch (NumberFormatException error) {
        Thread.yield();
        JOptionPane.showMessageDialog(
                this, "Error on parameter value: The"
                        + " Size of the Result List must be a integer value greater" + " or equal to 1.",
                "Application Error", JOptionPane.ERROR_MESSAGE);
        return;
    }

    /* SELETOR DE CARACTERISTICAS PARA O TREINAMENTO. */
    FS fs = new FS(strainingset, n, c, penalization_type, alpha, beta, q_entropy, resultsetsize);

    jProgressBarSE.setValue(10);
    Thread.yield();

    int maxfeatures = (Integer) jS_MaxSetSizeSE.getValue();
    if (maxfeatures <= 0) {
        JOptionPane.showMessageDialog(this, "Error on parameter value: The"
                + " Maximum Set Size be a integer value greater" + " or equal to 1.", "Application Error",
                JOptionPane.ERROR_MESSAGE);
        return;
    }

    if (selector == 1) {
        fs.runSFS(false, maxfeatures);
        jProgressBarSE.setValue(90);
        Thread.yield();
    } else if (selector == 3) {
        fs.runSFFS(maxfeatures, -1, null);
        jProgressBarSE.setValue(90);
        Thread.yield();
    } else if (selector == 2) {
        fs.runSFS(true, maxfeatures); /* a call to SFS is made in order to get the
                                      //ideal dimension to run the exhaustive search;*/
        int itmax = fs.itmax;
        if (itmax < maxfeatures) {
            itmax = maxfeatures;
        }
        /*calculating the estimated time to be completed in rea
        computer of 2 GHz*/
        int combinations = 0;
        for (int i = 1; i <= itmax; i++) {
            combinations += MathRoutines.numberCombinations(columns - 1, i);
        }
        double estimatedTime = (0.0062 + 3.2334e-7 * strainingset.length) * combinations
                * Math.log(combinations) / Math.log(2);
        int answer = JOptionPane.showConfirmDialog(null,
                "Estimated " + "time to finish: " + estimatedTime + " s.\n Do you want to" + " continue?",
                "Exhaustive Search", JOptionPane.YES_NO_OPTION);
        if (answer == 1) {
            jProgressBarSE.setValue(0);
            return;
        }
        //System.out.println("Estimated time to finish: "+estimatedTime+" s");
        float new_itmax = itmax;
        FS fsPrev = new FS(strainingset, n, c, penalization_type, alpha, beta, q_entropy, resultsetsize);
        for (int i = 1; i <= itmax; i++) {
            System.out.println("Iteration " + i);
            fs = new FS(strainingset, n, c, penalization_type, alpha, beta, q_entropy, resultsetsize);
            fs.itmax = i;
            fs.runExhaustive(0, 0, fs.I);
            //if (fs.hGlobal == 0) {
            //    break;
            //}
            if (fs.hGlobal < fsPrev.hGlobal) {
                fsPrev = fs;
            } else {
                fs = fsPrev;
                break;
            }
            float new_i = i;
            float pb = (new_i / new_itmax);
            pb = (pb * 80.0f);
            jProgressBarSE.setValue(10 + (int) pb);
            Thread.yield();
        }
    }

    /*
    jTA_SelectedFeaturesSE.setText("1st Global Criterion Function Value: " + fs.hGlobal);
    jTA_SelectedFeaturesSE.append("\nSelected Features: ");
    for (int i = 0; i < fs.I.size(); i++) {
    jTA_SelectedFeaturesSE.append(fs.I.elementAt(i) + " ");
    }
     * substituido pelo codigo abaixo para exibir uma lista de resultados
     * de tamanho escolhido pelo usuario.
     */
    for (int i = 0; i < fs.resultlist.size(); i++) {
        float fsvalue = ((Float) fs.resultlist.get(i).get(0));
        if (i == 0) {
            jTA_SelectedFeaturesSE.setText((i + 1) + "st Global Criterion" + " Function Value: " + fsvalue);
        } else if (i == 1) {
            jTA_SelectedFeaturesSE
                    .append("\n\n" + (i + 1) + "nd Global" + " Criterion Function Value: " + fsvalue);
        } else if (i == 2) {
            jTA_SelectedFeaturesSE
                    .append("\n\n" + (i + 1) + "rd Global" + " Criterion Function Value: " + fsvalue);
        } else {
            jTA_SelectedFeaturesSE
                    .append("\n\n" + (i + 1) + "th Global" + " Criterion Function Value: " + fsvalue);
        }
        jTA_SelectedFeaturesSE.append("\nSelected Features: ");
        Vector features = (Vector) fs.resultlist.get(i).get(1);
        for (int j = 0; j < features.size(); j++) {
            jTA_SelectedFeaturesSE.append((Integer) features.get(j) + " ");
        }
    }

    // CLASSIFICADOR.
    Classifier clas = new Classifier();
    clas.classifierTable(strainingset, fs.I, n, c);
    for (int i = 0; i < clas.table.size(); i++) {
        double[] tableLine = (double[]) clas.table.elementAt(i);
        double instance = (Double) clas.instances.elementAt(i);
        System.out.print(instance + " ");
        for (int j = 0; j < c; j++) {
            System.out.print((int) tableLine[j] + " ");
        }
        System.out.println();
    }
    jProgressBarSE.setValue(95);
    Thread.yield();
    double[] instances = clas.classifyTestSamples(stestset, fs.I, n, c);
    jTA_SaidaSE.setText("Correct Labels  -  Classified Labels - "
            + "Classification Instances\n(Considering the first selected" + " features)\n");
    double hits = 0;
    for (int i = 0; i < clas.labels.length; i++) {
        int correct_label = (int) stestset[i][columns - 1];
        int classified_label = (int) clas.labels[i];
        jTA_SaidaSE.append("\n" + correct_label + "  -  " + classified_label + "  -  " + instances[i]);
        if (correct_label == classified_label) {
            hits++;
        }
        Thread.yield();
    }
    double hit_rate = hits / clas.labels.length;
    jTA_SaidaSE.append("\nrate of hits = " + hit_rate);
    jProgressBarSE.setValue(100);
    Thread.yield();
}

From source file:com.biosis.biosislite.vistas.inventario.MantenimientoProveedor.java

private void btnguardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnguardarActionPerformed
    // TODO add your handling code here:
    List<Integer> array = new ArrayList();

    array.add(FormularioUtil.Validar(FormularioUtil.TipoValidacion.LETRA, this.telefonoField, "telefono"));
    array.add(FormularioUtil.Validar(FormularioUtil.TipoValidacion.LETRA, this.rucField, "ruc"));
    //        array.add(FormularioUtil.Validar(FormularioUtil.TipoValidacion.NUMERO, this.direccionField, "direccion"));
    array.add(// w ww . j  a  v  a2 s .com
            FormularioUtil.Validar(FormularioUtil.TipoValidacion.NUMERO, this.nombreField, "nombreProveedor"));

    FormularioUtil.validar2(array);

    if (FormularioUtil.error) {
        JOptionPane.showMessageDialog(null, FormularioUtil.mensaje, "Mensaje del Sistema",
                JOptionPane.ERROR_MESSAGE);
        FormularioUtil.mensaje = "";
        FormularioUtil.error = false;
    } else {
        String palabra = "";
        String palabra2 = "";
        if (accion == 1) {
            palabra = "registrar";
            palabra2 = "registrado";

            if (JOptionPane.showConfirmDialog(null, "Desea " + palabra + " el Proveedor?",
                    "Mensaje del Sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
                //                    proveedorControlador.getSeleccionado().setDni(idField.getText().toUpperCase());
                proveedorControlador.getSeleccionado().setNombreProveedor(nombreField.getText().toUpperCase());
                proveedorControlador.getSeleccionado().setDireccion(direccionField.getText().toUpperCase());
                proveedorControlador.getSeleccionado().setRuc(rucField.getText().toUpperCase());
                proveedorControlador.getSeleccionado().setTelefono(telefonoField.getText().toUpperCase());

                proveedorControlador.accion(accion);
                lista.add(proveedorControlador.getSeleccionado());

                if (accion == 1) {
                    JOptionPane.showMessageDialog(null, "Proveedor " + palabra2 + " correctamente",
                            "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE);
                    FormularioUtil.limpiarComponente(panelDatos);
                } else {
                    JOptionPane.showMessageDialog(null, "Proveedor no " + palabra2, "Mensaje del Sistema",
                            JOptionPane.ERROR_MESSAGE);
                }
            } else {
                FormularioUtil.limpiarComponente(panelDatos);
                JOptionPane.showMessageDialog(null, "Proveedor no " + palabra2, "Mensaje del Sistema",
                        JOptionPane.ERROR_MESSAGE);
            }
        } else if (accion == 2) {
            palabra = "modificar";
            palabra2 = "modificado";

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

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

                    lista.clear();
                    proveedorControlador.getSeleccionado()
                            .setNombreProveedor(nombreField.getText().toUpperCase());
                    proveedorControlador.getSeleccionado().setDireccion(direccionField.getText().toUpperCase());
                    proveedorControlador.getSeleccionado().setRuc(rucField.getText().toUpperCase());
                    proveedorControlador.getSeleccionado().setTelefono(telefonoField.getText().toUpperCase());

                    proveedorControlador.accion(accion);
                    listar();

                    FormularioUtil.limpiarComponente(panelDatos);

                } else {
                    JOptionPane.showMessageDialog(null, "Proveedor no " + palabra2, "Mensaje del Sistema",
                            JOptionPane.ERROR_MESSAGE);
                }
            } else {
                FormularioUtil.limpiarComponente(panelDatos);
                JOptionPane.showMessageDialog(null, "Proveedor no " + palabra2, "Mensaje del Sistema",
                        JOptionPane.ERROR_MESSAGE);
            }
        }

        FormularioUtil.limpiarComponente(panelDatos);
        FormularioUtil.activarComponente(panelOpciones, true);
        FormularioUtil.activarComponente(panelGuardar, false);
        FormularioUtil.activarComponente(panelDatos, false);
    }
}

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

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

        Integer codigo = tblambientes.getSelectedRow();

        Ambiente ambiente = ambienteControlador.buscarPorId(lista.get(codigo).getCodigo());

        if (ambiente != null) {
            if (JOptionPane.showConfirmDialog(null, "Desea Eliminar la Ambiente?", "Mensaje del Sistema",
                    JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {

                int[] filas = tblambientes.getSelectedRows();
                for (int i = 0; i < filas.length; i++) {
                    Ambiente ambiente2 = lista.get(filas[0]);
                    lista.remove(ambiente2);
                    ambienteControlador.setSeleccionado(ambiente2);
                    ambienteControlador.accion(accion);
                }
                if (ambienteControlador.accion(accion) == 3) {
                    JOptionPane.showMessageDialog(null, "Ambiente eliminada correctamente",
                            "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE);

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

From source file:com.holycityaudio.SpinCAD.SpinCADFile.java

public void fileSaveHex(SpinCADBank bank) {
    // Create a file chooser
    String savedPath = prefs.get("MRUHexFolder", "");

    final JFileChooser fc = new JFileChooser(savedPath);
    FileNameExtensionFilter filter = new FileNameExtensionFilter("Hex Files", "hex");
    fc.setFileFilter(filter);//from   www  . j av a  2 s .  c om
    fc.showSaveDialog(new JFrame());
    File fileToBeSaved = fc.getSelectedFile();

    if (!fc.getSelectedFile().getAbsolutePath().endsWith(".hex")) {
        fileToBeSaved = new File(fc.getSelectedFile() + ".hex");
    }
    int n = JOptionPane.YES_OPTION;
    if (fileToBeSaved.exists()) {
        JFrame frame1 = new JFrame();
        n = JOptionPane.showConfirmDialog(frame1, "Would you like to overwrite it?", "File already exists!",
                JOptionPane.YES_NO_OPTION);
    }
    if (n == JOptionPane.YES_OPTION) {
        String filePath;
        try {
            filePath = fileToBeSaved.getPath();
            fileToBeSaved.delete();
        } finally {
        }
        for (int i = 0; i < 8; i++) {
            try {
                if (bank.patch[i].isHexFile) {
                    fileSaveHex(i, bank.patch[i].hexFile, filePath);
                } else {
                    fileSaveHex(i, bank.patch[i].patchModel.getRenderBlock().generateHex(), filePath);
                }
            } catch (IOException e) {
                JOptionPane.showOptionDialog(null, "File save error!", "Error", JOptionPane.YES_NO_OPTION,
                        JOptionPane.QUESTION_MESSAGE, null, null, null);

                e.printStackTrace();
            }
        }
        saveMRUHexFolder(filePath);
    }
}

From source file:com.firmansyah.imam.sewa.kendaraan.FormUser.java

private void btnAktifActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAktifActionPerformed
    String status = btnAktif.getText();
    String id = inputIdUser.getText();

    System.out.println("Memilih ID : " + id);

    if (status.equals("Aktifkan")) {
        status = "1";
    } else {// w ww .j av a2s  . c  o  m
        status = "0";
    }

    int dialogButton = JOptionPane.YES_NO_OPTION;
    int dialogResult;
    dialogResult = JOptionPane.showConfirmDialog(this, "Anda yakin Ingin Mengubah Status User ini? ",
            "Konfirmasi", dialogButton);

    if (dialogResult == 0) {
        String url = Path.serverURL + "/user/status/" + id + "/" + status;

        getDataURL dataurl = new getDataURL();

        try {
            String data = dataurl.getData(url);
            System.out.println(data);

            if (data.equals("1")) {
                JOptionPane.showMessageDialog(this, "Status Berhasil diubah", "Informasi",
                        JOptionPane.INFORMATION_MESSAGE);

                System.out.println("Mengubah Status Data ID : " + id);
            } else {
                JOptionPane.showMessageDialog(this, "Status Tidak Berhasil diubah", "Informasi",
                        JOptionPane.ERROR_MESSAGE);
            }

        } catch (IOException ex) {
            Logger.getLogger(FormUser.class.getName()).log(Level.SEVERE, null, ex);
        }
    } else {
        System.out.println("Tidak Mengubah Status dari ID : " + id);
    }

    // refresh form
    refreshForm();

}