Example usage for javax.swing JOptionPane showConfirmDialog

List of usage examples for javax.swing JOptionPane showConfirmDialog

Introduction

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

Prototype

public static int showConfirmDialog(Component parentComponent, Object message, String title, int optionType)
        throws HeadlessException 

Source Link

Document

Brings up a dialog where the number of choices is determined by the optionType parameter.

Usage

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

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

        Integer codigo = tblProveedor.getSelectedRow();

        Proveedor proveedor = lista.get(codigo);

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

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

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

From source file:com.opendoorlogistics.studio.appframe.AppFrame.java

@Override
public boolean canCloseDatastore() {
    if (loaded == null) {
        return true;
    }/*  w ww  .  jav  a  2s  . co  m*/

    // if (loaded.isModified()) {
    if (datastoreCloseNeedsUseConfirmation) {
        if (JOptionPane.showConfirmDialog(this, "Any unsaved work will be lost. Do you want to exit?",
                "Confirm exit", JOptionPane.OK_CANCEL_OPTION) != JOptionPane.OK_OPTION) {
            return false;
        }
    }
    // }

    return true;
}

From source file:com.proyecto.vista.MantenimientoPeriodo.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 + " la Periodo?", "Mensaje del Sistema",
                JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {

            periodoControlador.setearVigenteFalse();
            periodoControlador.getSeleccionado().setPeriodo(Integer.parseInt(periodoField.getText()));
            periodoControlador.getSeleccionado().setFechaCreacion(jDateFecha.getDate());
            periodoControlador.getSeleccionado().setVigente(chckVigente.isSelected());

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

            if (accion == 1) {
                JOptionPane.showMessageDialog(null, "Periodo " + palabra2 + " correctamente",
                        "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE);
                FormularioUtil.limpiarComponente(panelDatos);
            } else {
                JOptionPane.showMessageDialog(null, "Periodo no " + palabra2, "Mensaje del Sistema",
                        JOptionPane.ERROR_MESSAGE);
            }/* w  w w .  j a  va  2  s . com*/
        } else {
            FormularioUtil.limpiarComponente(panelDatos);
            JOptionPane.showMessageDialog(null, "Periodo no " + palabra2, "Mensaje del Sistema",
                    JOptionPane.ERROR_MESSAGE);
        }
    } else if (accion == 2) {
        palabra = "modificar";
        palabra2 = "modificado";

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

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

                lista.clear();
                periodoControlador.getSeleccionado().setPeriodo(Integer.parseInt(periodoField.getText()));
                periodoControlador.getSeleccionado().setFechaCreacion(jDateFecha.getDate());
                periodoControlador.getSeleccionado().setVigente(chckVigente.isSelected());
                periodoControlador.accion(accion);
                listar();

                FormularioUtil.limpiarComponente(panelDatos);

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

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

From source file:com.biosis.biosislite.vistas.inventario.MantenimientoFactura.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.nombreField, "Nombre"));
    FormularioUtil.validar2(array);//from   w  ww .  ja v  a 2  s  .  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 + " el Tipo?", "Mensaje del Sistema",
                    JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {

                facturaControlador.getSeleccionado().setNumeroFactura(nombreField.getText());
                facturaControlador.getSeleccionado().setFecha(jDateFecha.getDate());
                facturaControlador.getSeleccionado().setRuta(facturaField.getText());

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

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

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

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

                    lista.clear();
                    facturaControlador.getSeleccionado().setNumeroFactura(nombreField.getText());
                    facturaControlador.getSeleccionado().setFecha(jDateFecha.getDate());
                    facturaControlador.getSeleccionado().setRuta(facturaField.getText());
                    facturaControlador.accion(accion);
                    listar();

                    FormularioUtil.limpiarComponente(panelDatos);

                } else {
                    JOptionPane.showMessageDialog(null, "Tipo no " + palabra2, "Mensaje del Sistema",
                            JOptionPane.ERROR_MESSAGE);
                }
            } else {
                FormularioUtil.limpiarComponente(panelDatos);
                JOptionPane.showMessageDialog(null, "Tipo no " + palabra2, "Mensaje del Sistema",
                        JOptionPane.ERROR_MESSAGE);
            }
        }
        FormularioUtil.limpiarComponente(panelDatos);
        FormularioUtil.limpiarComponente(panelFoto);
        FormularioUtil.activarComponente(panelOpciones, true);
        FormularioUtil.activarComponente(panelGuardar, false);
        FormularioUtil.activarComponente(panelDatos, false);
        lblFactura.setIcon(null);
    }

}

From source file:net.chaosserver.timelord.swingui.CommonTaskPanel.java

/**
 * Catch action events generated by the popup menu.
 *
 * @param evt the event//from  ww w  .  j a  v  a2  s  . c om
 */
public void actionPerformed(ActionEvent evt) {
    if (log.isTraceEnabled()) {
        log.trace("Got ActionEvent.getActionCommand [" + evt.getActionCommand() + "]");
    }

    if (CommonTaskPopupMenu.ACTION_ADDTASK.equals(evt.getActionCommand())) {
        showAddTaskDialog();
    } else if (CommonTaskPopupMenu.ACTION_ADDTIME.equals(evt.getActionCommand())) {
        showAddTimeDialog();
    } else if (CommonTaskPopupMenu.ACTION_DELTASK.equals(evt.getActionCommand())) {
        TaskDayPanel taskDayPanel = popupMenu.getTaskDayPanel();

        if (taskDayPanel != null) {
            TimelordTask timelordTask = taskDayPanel.getTimelordTask();

            int result = JOptionPane.showConfirmDialog(this,
                    "Delete [" + timelordTask.getTaskName() + "] Task?", "Delete Task",
                    JOptionPane.YES_NO_OPTION);

            if (result == 0) {
                getTimelordData().removeTask(timelordTask);
            }
        }
    } else if (CommonTaskPopupMenu.ACTION_RENTASK.equals(evt.getActionCommand())) {
        TaskDayPanel taskDayPanel = popupMenu.getTaskDayPanel();
        TimelordTask timelordTask = taskDayPanel.getTimelordTask();

        String newName = JOptionPane.showInputDialog(this, "Rename Task", timelordTask.getTaskName());

        if (newName != null) {
            if (taskDayPanel != null) {
                timelordTask.setTaskName(newName);
                getTimelordData().sortTaskCollection();
            }
        }
    } else if (CommonTaskPopupMenu.ACTION_EXPORT.equals(evt.getActionCommand())) {
        TaskDayPanel taskDayPanel = popupMenu.getTaskDayPanel();

        if (taskDayPanel != null) {
            TimelordTask timelordTask = taskDayPanel.getTimelordTask();
            timelordTask.setExportable(!timelordTask.isExportable());
        }
    } else if (CommonTaskPopupMenu.ACTION_HIDETASK.equals(evt.getActionCommand())) {
        TaskDayPanel taskDayPanel = popupMenu.getTaskDayPanel();

        if (taskDayPanel != null) {
            TimelordTask timelordTask = taskDayPanel.getTimelordTask();

            if (timelordTask.isHidden()) {
                timelordTask.setHidden(false);
            } else {
                timelordTask.setHidden(true);
            }
        }
    } else if (CommonTaskPopupMenu.ACTION_EDITNOTE.equals(evt.getActionCommand())) {
        TaskDayPanel taskDayPanel = popupMenu.getTaskDayPanel();

        if (taskDayPanel != null) {
            TimelordTask timelordTask = taskDayPanel.getTimelordTask();
            showEditNoteDialog(timelordTask);
        }
    } else if (ACTION_SEARCHTEXT.equals(evt.getActionCommand())) {
        if (log.isDebugEnabled()) {
            log.debug("Executing search with given input:" + searchTextField.getText());
            this.setTasknameFilter(searchTextField.getText());
        }
    }

}

From source file:com._17od.upm.gui.DatabaseActions.java

private boolean getLatestVersionOfDatabase() throws TransportException, ProblemReadingDatabaseFile, IOException,
        CryptoException, PasswordDatabaseException {
    boolean latestVersionDownloaded = false;

    // Ensure we're working with the latest version of the database
    if (databaseHasRemoteInstance() && localDatabaseDirty) {
        int answer = JOptionPane.showConfirmDialog(mainWindow, Translator.translate("askSyncWithRemoteDB"),
                Translator.translate("syncDatabase"), JOptionPane.YES_NO_OPTION);
        if (answer == JOptionPane.YES_OPTION) {
            latestVersionDownloaded = syncWithRemoteDatabase();
        }/*from  www .j  av a  2 s.  c  o m*/
    } else {
        latestVersionDownloaded = true;
    }

    return latestVersionDownloaded;
}

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

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

        @Override//from www  . j  a v  a 2s . co m
        public void actionPerformed(ActionEvent e) {
            Object kind = JOptionPane.showInputDialog(frame, title, "", JOptionPane.OK_CANCEL_OPTION, null,
                    serverProperties.getTables(), null);
            if (kind != null) {
                String confirm = TextUtil.getText("CONFIRM REMOVE") + " " + kind;
                if (JOptionPane.showConfirmDialog(frame, confirm, "",
                        JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
                    List<String> kindList = new ArrayList<String>();
                    kindList.add(kind.toString());
                    int count = dss.remove(kindList);
                    JOptionPane.showMessageDialog(frame, TextUtil.getText("REMOVED") + " " + count);
                }
            }
        }
    };
    removeEntityAction = createActionListener(frame, removeEntityAction);
    removeEntityItem.addActionListener(removeEntityAction);
    return removeEntityItem;
}

From source file:es.emergya.ui.plugins.admin.aux1.SummaryAction.java

private JFrame createJDialog(final String titulo) {
    final JFrame d = new JFrame(titulo);
    d.setResizable(false);//from   www  . j  a va  2 s  . c om
    d.setAlwaysOnTop(true);
    d.setIconImage(window.getIconImage());
    d.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    d.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            super.windowClosing(e);
            if (cambios) {
                int res = JOptionPane.showConfirmDialog(d,
                        "Existen cambios sin guardar. Seguro que desea cerrar la ventana?",
                        "Cambios sin guardar", JOptionPane.OK_CANCEL_OPTION);
                if (res != JOptionPane.CANCEL_OPTION) {
                    e.getWindow().dispose();
                }
            } else {
                e.getWindow().dispose();
            }
        }
    });
    d.setLayout(new BorderLayout(5, 5));
    d.setBackground(Color.WHITE);
    d.getContentPane().setBackground(Color.WHITE);
    return d;
}

From source file:jhplot.HPlotChart.java

/**
* Exports the image to some graphic format.
*///from   w w w.ja  v a 2  s .co m
private void exportDialog() {

    final JFileChooser fc = jhplot.gui.CommonGUI.openImageFileChooser(frame);

    if (fc.showDialog(frame, "Export to ") == 0) {
        // final File scriptFile = fileChooser.getSelectedFile();
        final File scriptFile = jhplot.io.images.ExportVGraphics.getSelectedFileWithExtension(fc);
        // System.out.println(scriptFile.getAbsolutePath());

        if (scriptFile == null)
            return;
        else if (scriptFile.exists()) {
            int res = JOptionPane.showConfirmDialog(frame,
                    "The file exists. Do you want to overwrite the file?", "", JOptionPane.YES_NO_OPTION);
            if (res == JOptionPane.NO_OPTION)
                return;
        }
        String mess = "write image  file ..";
        Thread t = new Thread(mess) {
            public void run() {
                export(scriptFile.getAbsolutePath());
            };
        };
        t.start();
    }

}

From source file:com.floreantpos.ui.views.payment.SettleTicketDialog.java

public void settleTicket(PosTransaction transaction) {
    try {//from  www  .  ja v  a2  s .  c o m
        final double dueAmount = ticket.getDueAmount();

        confirmLoyaltyDiscount(ticket);

        PosTransactionService transactionService = PosTransactionService.getInstance();
        transactionService.settleTicket(ticket, transaction);

        //FIXME
        printTicket(ticket, transaction);

        showTransactionCompleteMsg(dueAmount, transaction.getTenderAmount(), ticket, transaction);

        if (ticket.getDueAmount() > 0.0) {
            int option = JOptionPane.showConfirmDialog(Application.getPosWindow(),
                    POSConstants.CONFIRM_PARTIAL_PAYMENT, POSConstants.MDS_POS, JOptionPane.YES_NO_OPTION);

            if (option != JOptionPane.YES_OPTION) {

                setCanceled(false);
                dispose();
            }

            setTicket(ticket);
        } else {
            setCanceled(false);
            dispose();
        }
    } catch (UnknownHostException e) {
        POSMessageDialog.showError(Application.getPosWindow(), Messages.getString("SettleTicketDialog.12")); //$NON-NLS-1$
    } catch (Exception e) {
        POSMessageDialog.showError(this, POSConstants.ERROR_MESSAGE, e);
    }
}