Example usage for javax.swing JOptionPane DEFAULT_OPTION

List of usage examples for javax.swing JOptionPane DEFAULT_OPTION

Introduction

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

Prototype

int DEFAULT_OPTION

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

Click Source Link

Document

Type meaning Look and Feel should not supply any options -- only use the options from the JOptionPane.

Usage

From source file:Form.Principal.java

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    try {/*from www .  j  a  v a 2 s .  c  o m*/
        String Comando = null;
        if (jTextField3.getText().equalsIgnoreCase("") || jTextField5.getText().equalsIgnoreCase("")
                || jTextField6.getText().equalsIgnoreCase("") || jTextField7.getText().equalsIgnoreCase("")
                || jTextField8.getText().equalsIgnoreCase("") || jTextField9.getText().equalsIgnoreCase("")
                || jTextField10.getText().equalsIgnoreCase("") || jTextField11.getText().equalsIgnoreCase("")) {
            Object[] options = { "Aceptar" };
            JOptionPane.showOptionDialog(null, "Datos incompletos", "Aviso", JOptionPane.DEFAULT_OPTION,
                    JOptionPane.WARNING_MESSAGE, null, options, options[0]);
        } else {
            Comando = "INSERT INTO cliente VALUES (default,'" + jTextField5.getText() + "','"
                    + jTextField6.getText() + "','" + jTextField10.getText() + "','" + jTextField9.getText()
                    + "','" + jTextField7.getText() + "','" + jTextField8.getText() + "','"
                    + jTextField3.getText() + "','" + jTextField11.getText() + "'); ";
            Funcion.Update(st, Comando);
            Autocompletar.removeAllItems();
            Autocompletar = new TextAutoCompleter(jTextField2);
            Comandos = Funcion.Select(st, "SELECT * FROM cliente;");
            try {
                while (Comandos.next()) {
                    Autocompletar.addItem(Comandos.getString("RFC"));
                }
            } catch (SQLException ex) {
                //Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
            }
            //*******Limpiar
            jTextField5.setText("");
            jTextField6.setText("");
            jTextField10.setText("");
            jTextField8.setText("");
            jTextField9.setText("");
            jTextField7.setText("");
            jTextField3.setText("");
            jTextField11.setText("");
            jPanel7.setVisible(false);
            jButton2.setVisible(false);
            //jPanel6.setVisible(false);
            //jButton1.setVisible(false);
            jButton1.setEnabled(true);

            Object[] options = { "Aceptar" };
            JOptionPane.showOptionDialog(null, "Exito!", "Nuevo cliente", JOptionPane.DEFAULT_OPTION,
                    JOptionPane.WARNING_MESSAGE, null, options, options[0]);

            /*jButton8.setVisible(true);
            jButton9.setVisible(true);
            jButton10.setVisible(true);
            jButton3.setVisible(true);
            jButton11.setVisible(true); 
            FechaSistema();
            factura();
            CrearPanelPDF();*/
        }

    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "Error en los datos" + e.getMessage());
    }

}

From source file:com.nikonhacker.gui.EmulatorUI.java

private void openDecodeDialog() {
    JTextField sourceFile = new JTextField();
    JTextField destinationDir = new JTextField();
    FileSelectionPanel sourceFileSelectionPanel = new FileSelectionPanel("Source file", sourceFile, false);
    sourceFileSelectionPanel.setFileFilter(".bin", "Firmware file (*.bin)");
    final JComponent[] inputs = new JComponent[] { sourceFileSelectionPanel,
            new FileSelectionPanel("Destination dir", destinationDir, true) };
    if (JOptionPane.OK_OPTION == JOptionPane.showOptionDialog(this, inputs,
            "Choose source file and destination dir", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE,
            null, null, JOptionPane.DEFAULT_OPTION)) {
        try {// w  w w  .ja  v  a 2s.  c  om
            new FirmwareDecoder().decode(sourceFile.getText(), destinationDir.getText(), false);
            JOptionPane.showMessageDialog(this, "Decoding complete", "Done", JOptionPane.INFORMATION_MESSAGE);
        } catch (FirmwareFormatException e) {
            JOptionPane.showMessageDialog(this, e.getMessage() + "\nPlease see console for full stack trace",
                    "Error decoding files", JOptionPane.ERROR_MESSAGE);
            e.printStackTrace();
        }
    }
}

From source file:ru.apertum.qsystem.client.forms.FAdmin.java

@Action
    public void addUser() {
        // ?    ?  ,  
        String userName = "";
        boolean flag = true;
        while (flag) {
            userName = (String) JOptionPane.showInputDialog(this, getLocaleMessage("admin.add_user_dialog.title"),
                    getLocaleMessage("admin.add_user_dialog.caption"), 3, null, null, userName);
            if (userName == null) {
                return;
            }//from   w w  w  .j  a  va  2  s  .com
            if ("".equals(userName)) {
                JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_user_dialog.err1.title"),
                        getLocaleMessage("admin.add_user_dialog.err1.caption"), JOptionPane.DEFAULT_OPTION,
                        JOptionPane.ERROR_MESSAGE);
            } else if (QUserList.getInstance().hasByName(userName)) {
                JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_user_dialog.err2.title"),
                        getLocaleMessage("admin.add_user_dialog.err2.caption"), JOptionPane.DEFAULT_OPTION,
                        JOptionPane.ERROR_MESSAGE);
            } else if (userName.indexOf('\"') != -1) {
                JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_user_dialog.err3.title"),
                        getLocaleMessage("admin.add_user_dialog.err3.caption"), JOptionPane.DEFAULT_OPTION,
                        JOptionPane.ERROR_MESSAGE);
            } else if (userName.length() > 150) {
                JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_user_dialog.err4.title"),
                        getLocaleMessage("admin.add_user_dialog.err4.caption"), JOptionPane.DEFAULT_OPTION,
                        JOptionPane.ERROR_MESSAGE);
            } else {
                flag = false;
            }
        }
        QLog.l().logger().debug("? ? \"" + userName + "\"");
        final QUser user = new QUser();
        user.setPlanServices(new LinkedList<>());
        user.setName(userName);
        user.setPassword("");
        user.setPoint("");
        user.setAdressRS(32);
        QUserList.getInstance().addElement(user);
        listUsers.setSelectedValue(user, true);
    }

From source file:com.nikonhacker.gui.EmulatorUI.java

private void openEncodeDialog() {
    JTextField destinationFile = new JTextField();
    JTextField sourceFile1 = new JTextField();
    JTextField sourceFile2 = new JTextField();
    FileSelectionPanel destinationFileSelectionPanel = new FileSelectionPanel("Destination file",
            destinationFile, false);/*from  ww  w .  j a  v a2s.  c  o m*/
    destinationFileSelectionPanel.setFileFilter(".bin", "Encoded firmware file (*.bin)");
    FileSelectionPanel sourceFile1SelectionPanel = new FileSelectionPanel("Source file 1", sourceFile1, false);
    destinationFileSelectionPanel.setFileFilter("a*.bin", "Decoded A firmware file (a*.bin)");
    FileSelectionPanel sourceFile2SelectionPanel = new FileSelectionPanel("Source file 2", sourceFile2, false);
    destinationFileSelectionPanel.setFileFilter("b*.bin", "Decoded B firmware file (b*.bin)");
    final JComponent[] inputs = new JComponent[] { destinationFileSelectionPanel, sourceFile1SelectionPanel,
            sourceFile2SelectionPanel };
    if (JOptionPane.OK_OPTION == JOptionPane.showOptionDialog(this, inputs,
            "Choose target encoded file and source files", JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.PLAIN_MESSAGE, null, null, JOptionPane.DEFAULT_OPTION)) {
        try {
            ArrayList<String> inputFilenames = new ArrayList<String>();
            inputFilenames.add(sourceFile1.getText());
            inputFilenames.add(sourceFile2.getText());
            new FirmwareEncoder().encode(inputFilenames, destinationFile.getText());
            JOptionPane.showMessageDialog(this, "Encoding complete", "Done", JOptionPane.INFORMATION_MESSAGE);
        } catch (FirmwareFormatException e) {
            JOptionPane.showMessageDialog(this, e.getMessage() + "\nPlease see console for full stack trace",
                    "Error encoding files", JOptionPane.ERROR_MESSAGE);
            e.printStackTrace();
        }
    }
}

From source file:com.nikonhacker.gui.EmulatorUI.java

private void openDecodeNkldDialog() {
    JTextField sourceFile = new JTextField();
    JTextField destinationFile = new JTextField();
    FileSelectionPanel sourceFileSelectionPanel = new FileSelectionPanel("Source file", sourceFile, false);
    sourceFileSelectionPanel.setFileFilter("nkld*.bin", "Lens correction data file (nkld*.bin)");
    final JComponent[] inputs = new JComponent[] { sourceFileSelectionPanel,
            new FileSelectionPanel("Destination file", destinationFile, true) };
    if (JOptionPane.OK_OPTION == JOptionPane.showOptionDialog(this, inputs,
            "Choose source file and destination dir", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE,
            null, null, JOptionPane.DEFAULT_OPTION)) {
        try {// w w w  .  j a v  a 2s .c  om
            new NkldDecoder().decode(sourceFile.getText(), destinationFile.getText(), false);
            JOptionPane
                    .showMessageDialog(
                            this, "Decoding complete.\nFile '"
                                    + new File(destinationFile.getText()).getAbsolutePath() + "' was created.",
                            "Done", JOptionPane.INFORMATION_MESSAGE);
        } catch (FirmwareFormatException e) {
            JOptionPane.showMessageDialog(this, e.getMessage() + "\nPlease see console for full stack trace",
                    "Error decoding files", JOptionPane.ERROR_MESSAGE);
            e.printStackTrace();
        }
    }
}

From source file:ru.apertum.qsystem.client.forms.FAdmin.java

@Action
    public void addNewUserByCopy() {
        if (listUsers.getSelectedIndex() != -1) {
            final QUser user = (QUser) listUsers.getSelectedValue();
            // ?    ?  ,  
            String userName = "";
            boolean flag = true;
            while (flag) {
                userName = (String) JOptionPane.showInputDialog(this,
                        getLocaleMessage("admin.add_user_dialog.title"),
                        getLocaleMessage("admin.add_user_dialog.caption"), 3, null, null, userName);
                if (userName == null) {
                    return;
                }/*from   w  ww.  j ava 2  s.  co m*/
                if ("".equals(userName)) {
                    JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_user_dialog.err1.title"),
                            getLocaleMessage("admin.add_user_dialog.err1.caption"), JOptionPane.DEFAULT_OPTION,
                            JOptionPane.ERROR_MESSAGE);
                } else if (QUserList.getInstance().hasByName(userName)) {
                    JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_user_dialog.err2.title"),
                            getLocaleMessage("admin.add_user_dialog.err2.caption"), JOptionPane.DEFAULT_OPTION,
                            JOptionPane.ERROR_MESSAGE);
                } else if (userName.indexOf('\"') != -1) {
                    JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_user_dialog.err3.title"),
                            getLocaleMessage("admin.add_user_dialog.err3.caption"), JOptionPane.DEFAULT_OPTION,
                            JOptionPane.ERROR_MESSAGE);
                } else if (userName.length() > 150) {
                    JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_user_dialog.err4.title"),
                            getLocaleMessage("admin.add_user_dialog.err4.caption"), JOptionPane.DEFAULT_OPTION,
                            JOptionPane.ERROR_MESSAGE);
                } else {
                    flag = false;
                }
            }
            QLog.l().logger().debug("? ? \"" + userName + "\"");
            final QUser newUser = new QUser();
            LinkedList<QPlanService> plan = new LinkedList<>();
            user.getPlanServices().stream().forEach((pl) -> {
                plan.add(new QPlanService(pl.getService(), pl.getUser(), pl.getCoefficient()));
            });
            newUser.setPlanServices(plan);
            newUser.setName(userName);
            newUser.setPassword("");
            newUser.setPoint(user.getPoint());
            newUser.setAdressRS(user.getAdressRS());
            newUser.setPointExt(user.getPointExt());
            newUser.setReportAccess(user.getReportAccess());
            newUser.setAdminAccess(user.getAdminAccess());
            newUser.setAdminAccess(user.getAdminAccess());
            QUserList.getInstance().addElement(newUser);
            listUsers.setSelectedValue(newUser, true);
        }
    }

From source file:com.pironet.tda.TDA.java

/**
 * save the current logfile (only used in plugin mode)
 *//*from   w  w  w .j  av a  2 s  .  c om*/
public void saveLogFile() {
    if (fc == null) {
        fc = new JFileChooser();
        fc.setMultiSelectionEnabled(true);
        fc.setCurrentDirectory(PrefManager.get().getSelectedPath());
    }
    if (firstFile && (PrefManager.get().getPreferredSizeFileChooser().height > 0)) {
        fc.setPreferredSize(PrefManager.get().getPreferredSizeFileChooser());
    }
    int returnVal = fc.showSaveDialog(this.getRootPane());
    fc.setPreferredSize(fc.getSize());
    PrefManager.get().setPreferredSizeFileChooser(fc.getSize());

    if (returnVal == JFileChooser.APPROVE_OPTION) {
        File file = fc.getSelectedFile();
        int selectValue = 0;
        if (file.exists()) {
            Object[] options = { "Overwrite", "Cancel" };
            selectValue = JOptionPane.showOptionDialog(null,
                    "<html><body>File exists<br><b>" + file + "</b></body></html>", "Confirm overwrite",
                    JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
        }
        if (selectValue == 0) {
            FileOutputStream fos = null;
            try {
                fos = new FileOutputStream(file);
                fos.write(((LogFileContent) logFile.getUserObject()).getContent().getBytes());
                fos.flush();
            } catch (IOException ex) {
                ex.printStackTrace();
            } finally {
                try {
                    fos.close();
                } catch (IOException ex) {
                    ex.printStackTrace();
                }
            }
        }
    }
}

From source file:ru.apertum.qsystem.client.forms.FAdmin.java

@Action
    public void renameUser() {
        if (listUsers.getSelectedIndex() != -1) {
            final QUser user = (QUser) listUsers.getSelectedValue();
            String userName = user.getName();
            boolean flag = true;
            while (flag) {
                userName = (String) JOptionPane.showInputDialog(this,
                        getLocaleMessage("admin.rename_user_dialog.title"),
                        getLocaleMessage("admin.rename_user_dialog.caption"), 3, null, null, userName);
                if (userName == null) {
                    return;
                }//from  w  ww  .  j  av a 2  s  .  c o m
                if ("".equals(userName)) {
                    JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.rename_user_dialog.err1.title"),
                            getLocaleMessage("admin.rename_user_dialog.err1.caption"), JOptionPane.DEFAULT_OPTION,
                            JOptionPane.ERROR_MESSAGE);
                } else if (QUserList.getInstance().hasByName(userName)) {
                    JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.rename_user_dialog.err2.title"),
                            getLocaleMessage("admin.rename_user_dialog.err2.caption"), JOptionPane.DEFAULT_OPTION,
                            JOptionPane.ERROR_MESSAGE);
                } else if (userName.indexOf('\"') != -1) {
                    JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.rename_user_dialog.err3.title"),
                            getLocaleMessage("admin.rename_user_dialog.err3.caption"), JOptionPane.DEFAULT_OPTION,
                            JOptionPane.ERROR_MESSAGE);
                } else if (userName.length() > 150) {
                    JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.rename_user_dialog.err4.title"),
                            getLocaleMessage("admin.rename_user_dialog.err4.caption"), JOptionPane.DEFAULT_OPTION,
                            JOptionPane.ERROR_MESSAGE);
                } else {
                    flag = false;
                }
            }
            user.setName(userName);
            textFieldUserName.setText(userName);
            listUsers.setSelectedValue(user, true);
        }
    }

From source file:Form.Principal.java

private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton13ActionPerformed
    try {/*from  www .  j  av a2 s .com*/
        String Comando = null;
        if (jTextField3.getText().equalsIgnoreCase("") || jTextField5.getText().equalsIgnoreCase("")
                || jTextField6.getText().equalsIgnoreCase("") || jTextField7.getText().equalsIgnoreCase("")
                || jTextField8.getText().equalsIgnoreCase("") || jTextField9.getText().equalsIgnoreCase("")
                || jTextField10.getText().equalsIgnoreCase("") || jTextField11.getText().equalsIgnoreCase("")) {
            Object[] options = { "Aceptar" };
            JOptionPane.showOptionDialog(null, "Datos incompletos", "Aviso", JOptionPane.DEFAULT_OPTION,
                    JOptionPane.WARNING_MESSAGE, null, options, options[0]);
        } else {
            Variables.NombreCliente = jTextField6.getText();
            Variables.Direccion = jTextField10.getText();
            Variables.Estado = jTextField7.getText();
            Variables.municipio = jTextField9.getText();
            Variables.delegacion = jTextField11.getText();
            Variables.Correo = jTextField3.getText();
            Variables.codpostal = jTextField8.getText();

            Comando = "UPDATE cliente SET NombreCliente='" + jTextField6.getText() + "',Direccion='"
                    + jTextField10.getText() + "',Estado='" + jTextField7.getText() + "',Municipio='"
                    + jTextField9.getText() + "',Localidad='" + jTextField11.getText() + "',codPostal='"
                    + jTextField8.getText() + "',correo='" + jTextField3.getText() + "' WHERE idCliente="
                    + Variables.idCliente + ";";
            Funcion.Update(st, Comando);

            Variables.Comentario = jTextField20.getText();
            //*******Limpiar
            jTextField5.setText("");
            jTextField6.setText("");
            jTextField10.setText("");
            jTextField8.setText("");
            jTextField9.setText("");
            jTextField7.setText("");
            jTextField3.setText("");
            jTextField11.setText("");
            jTextField20.setText("");
            jPanel7.setVisible(false);
            jButton2.setVisible(false);
            jPanel6.setVisible(false);
            jButton1.setVisible(false);
            jButton12.setVisible(false);
            jButton13.setVisible(false);
            jPanel13.setVisible(false);

            //jButton9.setVisible(true);
            //jButton10.setVisible(true);
            jButton3.setVisible(true);
            jButton11.setVisible(true);
            EnviarSAT.setVisible(true);
            CrearPanelPDF();
        }
    } catch (Exception e) {
        JOptionPane.showMessageDialog(this, e);
        System.out.print(e.getMessage());
        e.printStackTrace();
    }

}

From source file:ru.apertum.qsystem.client.forms.FAdmin.java

@Action
    public void deleteUser() {
        if (listUsers.getSelectedIndex() != -1) {
            if (JOptionPane.showConfirmDialog(this,
                    getLocaleMessage("admin.remove_user_dialog.title") + " \""
                            + ((QUser) listUsers.getSelectedValue()).getName() + "\"?",
                    getLocaleMessage("admin.remove_user_dialog.caption"), JOptionPane.YES_NO_OPTION) == 1) {
                return;
            }//from  w w w. java 2  s  .c  o m
            QLog.l().logger().debug("? ? \""
                    + ((QUser) listUsers.getSelectedValue()).getName() + "\"");

            final int del = listUsers.getSelectedIndex();
            final QUserList m = (QUserList) listUsers.getModel();
            final int col = m.getSize();

            final QUser user = (QUser) listUsers.getSelectedValue();
            //  ?  ? 
            if (user.getAdminAccess()) {
                int cnt = 0;
                for (int i = 0; i < listUsers.getModel().getSize(); i++) {
                    if (((QUser) listUsers.getModel().getElementAt(i)).getAdminAccess()) {
                        cnt++;
                    }
                }
                if (cnt == 1) {
                    JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.remove_user_dialog.err.title"),
                            getLocaleMessage("admin.remove_user_dialog.err.caption"), JOptionPane.DEFAULT_OPTION,
                            JOptionPane.INFORMATION_MESSAGE);
                    return;
                }
            }
            QUserList.getInstance().removeElement(user);

            if (col != 1) {
                if (col == del + 1) {
                    listUsers.setSelectedValue(m.getElementAt(del - 1), true);
                } else if (col > del + 1) {
                    listUsers.setSelectedValue(m.getElementAt(del), true);
                }
            }
        }
    }