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:org.panbox.desktop.common.gui.PanboxClientGUI.java

private boolean uneditedCSPsExist() {
    if (cspInfoTable.getModel() instanceof CSPTableModel) {
        CSPTableModel model = (CSPTableModel) cspInfoTable.getModel();
        if (model.getRowCount() > 0 && (model.getValueAt(model.getRowCount() - 1, 1) == null
                || model.getValueAt(model.getRowCount() - 1, 1).equals(""))) {
            JOptionPane.showConfirmDialog(null, bundle.getString("PanboxClientGUI.lastCSPNotFinished"),
                    bundle.getString("PanboxClientGUI.panboxMessage"), JOptionPane.DEFAULT_OPTION);
            return true;
        } else {//from  ww w.j  a v  a2s .  c  o m
            return false;
        }
    } else {
        return false;
    }
}

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

@Action
public void addBreak() {
    final GregorianCalendar gc = new GregorianCalendar(2015, 1, 1,
            Integer.parseInt(cbSH.getSelectedItem().toString()),
            Integer.parseInt(cbSM.getSelectedItem().toString()));
    final Date d1 = gc.getTime();
    gc.set(GregorianCalendar.HOUR_OF_DAY, Integer.parseInt(cbFH.getSelectedItem().toString()));
    gc.set(GregorianCalendar.MINUTE, Integer.parseInt(cbFM.getSelectedItem().toString()));
    if (d1.before(gc.getTime())) {
        breaks = (QBreak[]) ArrayUtils.add(breaks, new QBreak(d1, gc.getTime(), breaksParent));
        loadBreaks(breaks);//from   w  ww .  jav  a  2s . com
    } else {
        JOptionPane.showConfirmDialog(this, getLocaleMessage("add_break_dialog.err1.message"),
                getLocaleMessage("add_break_dialog.err1.title"), JOptionPane.DEFAULT_OPTION,
                JOptionPane.ERROR_MESSAGE);
    }
}

From source file:ru.medved.json.wssoap.WebServiceSamplerGui.java

/**
 * method from ActionListener/*from w w  w .  ja v  a 2 s .  c  o  m*/
 * 
 * @param event
 *            that occurred
 */
public void actionPerformed(ActionEvent event) {
    final Object eventSource = event.getSource();
    if (eventSource == selectButton) {
        this.configureFromWSDL();
    } else if (eventSource == useProxy) {
        // if use proxy is checked, we enable
        // the text fields for the host and port
        boolean use = useProxy.isSelected();
        if (use) {
            proxyHost.setEnabled(true);
            proxyPort.setEnabled(true);
        } else {
            proxyHost.setEnabled(false);
            proxyPort.setEnabled(false);
        }
    } else if (eventSource == wsdlButton) {
        final String wsdlText = wsdlField.getText();
        if (wsdlText != null && wsdlText.length() > 0) {
            fillWsdlMethods(wsdlText, false, null);
        } else {
            JOptionPane.showConfirmDialog(this, JMeterUtils.getResString("wsdl_url_error"), // $NON-NLS-1$
                    JMeterUtils.getResString("warning"), // $NON-NLS-1$
                    JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE);
        }
    }
}

From source file:se.trixon.mapollage.ui.MainFrame.java

private void showOptions() {
    OptionsPanel optionsPanel = new OptionsPanel();
    SwingHelper.makeWindowResizable(optionsPanel);

    Object[] options = new Object[] { AlmondOptionsPanel.getGlobalOptionsButton(optionsPanel), new JSeparator(),
            Dict.CANCEL, Dict.OK };/*from   w ww . j  av a2 s . c  om*/
    int retval = JOptionPane.showOptionDialog(this, optionsPanel, Dict.OPTIONS.toString(),
            JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, Dict.OK);

    if (retval == Arrays.asList(options).indexOf(Dict.OK)) {
        optionsPanel.save();
    }
}

From source file:skoa.helpers.ConfiguracionGraficas.java

private void verGraficaEnGrande(int i) {
    File dir = new File(ruta_graficos);
    String[] ficheros = dir.list();
    String ruta_aux = ruta_graficos + "\\" + ficheros[i] + "\\";
    String nombreImagen = ruta_aux + "EvolucionBig.jpg";
    File aux = new File(nombreImagen); //Creamos un fichero auxiliar con el nombre anterior.
    if (!aux.exists()) { //Comprobamos si existe. Sino existe, era una consulta B.
        nombreImagen = ruta_aux + "BarrasBig.jpg"; //Y cambiamos el nombre.
        aux = new File(nombreImagen);
        if (!aux.exists()) {
            nombreImagen = ruta_aux + "MaxMinMedBig.jpg"; //Y cambiamos el nombre.
            aux = new File(nombreImagen);
            if (!aux.exists())
                nombreImagen = ruta_aux + "DiferenciasBig.jpg"; //Cambia al ultimo nombre posible.
        }/*  ww w. ja v  a 2s .c  om*/
    }
    ImageIcon icon = new ImageIcon(nombreImagen);
    //JOptionPane.showMessageDialog(interfaz, icon, "Statistics", JOptionPane.CLOSED_OPTION);
    JOptionPane.showMessageDialog(interfaz, icon, "Estadsticas", JOptionPane.DEFAULT_OPTION);
    /*String string1 = "Acept"; //PARA INGLS
    Object[] options = {string1};
    JOptionPane.showOptionDialog(interfaz,
          "",
                             "Statistics",   //titulo de la ventana
                             JOptionPane.YES_OPTION,
                             JOptionPane.DEFAULT_OPTION,
                             icon,       //use a custom Icon
                             options,    //the titles of buttons
                             string1);    //the title of the default button
         */
}

From source file:tvbrowser.TVBrowser.java

private static void showTVBrowserIsAlreadyRunningMessageBox() {
    try {/* w w w  .ja v a  2s.  c  o m*/
        UIThreadRunner.invokeAndWait(new Runnable() {
            @Override
            public void run() {
                Object[] options = { Localizer.getLocalization(Localizer.I18N_CLOSE),
                        mLocalizer.msg("startAnyway", "start anyway") };
                if (JOptionPane.showOptionDialog(null,
                        mLocalizer.msg("alreadyRunning", "TV-Browser is already running"),
                        mLocalizer.msg("alreadyRunning", "TV-Browser is already running"),
                        JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options,
                        options[0]) != 1) {
                    System.exit(-1);
                }
            }
        });
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:view.CertificateManagementDialog.java

private void btnRemoveCertActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoveCertActionPerformed
    int[] indices = jList1.getSelectedIndices();
    if (indices.length != 0) {
        String msg = (indices.length == 1 ? Bundle.getBundle().getString("removeCert1")
                : Bundle.getBundle().getString("removeCert2") + " " + indices.length + " "
                        + Bundle.getBundle().getString("removeCert3"));

        Object[] options = { Bundle.getBundle().getString("yes"), Bundle.getBundle().getString("no") };
        int opt = JOptionPane.showOptionDialog(null, msg, "", JOptionPane.DEFAULT_OPTION,
                JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
        if (opt == JOptionPane.NO_OPTION) {
            return;
        }// w  ww . ja  v  a 2 s . co  m
        final ArrayList<Certificate> toRemove = new ArrayList<>();
        for (int index : indices) {
            toRemove.add(alTrusted.get(index));
        }

        String password = getUserInputPassword();
        if (password == null) {
            return;
        }
        for (Certificate cert : toRemove) {
            removeCertFromKeystore(cert, password);
            alTrusted.remove(cert);
        }
    }
}

From source file:view.MainWindow.java

public void closeDocument(boolean showCloseDialog) {
    if (!workspacePanel.getStatus().equals(WorkspacePanel.Status.READY)) {
        return;//from   w  w w .j a  v  a  2 s . c o m
    }

    if (!files.isEmpty()) {
        int opt = -1;
        if (showCloseDialog) {
            String msg;
            if (jtOpenedDocuments.getSelectionRows().length == 1) {
                msg = Bundle.getBundle().getString("msg.closeSelectedDocument");
            } else {
                msg = Bundle.getBundle().getString("msg.closeSelectedDocuments");
            }
            Object[] options = { Bundle.getBundle().getString("yes"), Bundle.getBundle().getString("no") };
            opt = JOptionPane.showOptionDialog(null, msg, "", JOptionPane.DEFAULT_OPTION,
                    JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
        }
        boolean closedOpenedDocument = false;
        if (!showCloseDialog || opt == JOptionPane.YES_OPTION) {
            // Apagar da lista de documentos abertos
            for (int i = jtOpenedDocuments.getSelectionRows().length - 1; i >= 0; i--) {
                int index = jtOpenedDocuments.getSelectionRows()[i];
                String path = jtOpenedDocuments.getPathForRow(index).getPathComponent(1).toString();
                files.remove(new File(path));
                if (null != openedFile) {
                    if (openedFile.equals(new File(path))) {
                        closedOpenedDocument = true;
                        clearOpenedDocument();
                        setTitle(null);
                    }
                }
            }
            dmtn.removeAllChildren();
            for (File file : files) {
                dmtn.insert(new DefaultMutableTreeNode(file), 0);
            }
            int numOpened = dmtn.getChildCount();
            if (1 == numOpened) {
                lblOpenedDocuments.setText("1 " + Bundle.getBundle().getString("tn.documentLoaded") + " :");
                dmtn.setUserObject(null);
            } else {
                lblOpenedDocuments
                        .setText(numOpened + " " + Bundle.getBundle().getString("tn.documentsLoaded") + ":");
                dmtn.setUserObject(null);
            }
            TreeModel tm = new DefaultTreeModel(dmtn);
            jtOpenedDocuments.setModel(tm);
            if (closedOpenedDocument && !files.isEmpty()) {
                File first = files.get(files.size() - 1);
                jtOpenedDocuments.setSelectionRow(0);
                ctrl.openDocument(first.getAbsolutePath());
                workspacePanel.setDocument(ctrl.getDocument());
                openedFile = first;
            }
        }
    }
}

From source file:view.MainWindow.java

public void closeDocuments(ArrayList<File> listaD, boolean showCloseDialog) {
    if (workspacePanel.getStatus().equals(WorkspacePanel.Status.SIGNING)) {
        if (listaD.contains(openedFile)) {
            String msg = Bundle.getBundle().getString("msg.cancelSignatureAndClose1") + " "
                    + (listaD.size() == 1 ? Bundle.getBundle().getString("msg.cancelSignatureAndClose2")
                            : Bundle.getBundle().getString("msg.cancelSignatureAndClose3"));
            Object[] options = { Bundle.getBundle().getString("yes"), Bundle.getBundle().getString("no") };
            int opt = JOptionPane.showOptionDialog(this, msg, "", JOptionPane.DEFAULT_OPTION,
                    JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
            if (opt != JOptionPane.YES_OPTION) {
                return;
            }/*from www .j  a va  2s . co m*/
        }
    }

    if (!listaD.isEmpty()) {
        int opt = -1;
        if (showCloseDialog) {
            String msg;
            if (listaD.size() == 1) {
                msg = Bundle.getBundle().getString("msg.closeSelectedDocument");
            } else {
                msg = Bundle.getBundle().getString("msg.closeSelectedDocuments");
            }

            Object[] options = { Bundle.getBundle().getString("yes"), Bundle.getBundle().getString("no") };
            opt = JOptionPane.showOptionDialog(null, msg, "", JOptionPane.DEFAULT_OPTION,
                    JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
        }
        if (!showCloseDialog || opt == JOptionPane.YES_OPTION) {
            // Apagar da lista de documentos abertos
            boolean closedOpenedDocument = false;
            for (int r = jtOpenedDocuments.getRowCount() - 1; r >= 0; r--) {
                String str = "";
                Object[] paths = jtOpenedDocuments.getPathForRow(r).getPath();
                for (int i = 1; i < paths.length; i++) {
                    str += paths[i];
                    if (i + 1 < paths.length) {
                        str += File.separator;
                    }
                }
                File currFile = new File(str.replaceAll("\\\\+", "\\\\"));
                for (File f : listaD) {
                    if (f.getAbsolutePath().replaceAll("\\\\+", "\\\\").equals(currFile.getAbsolutePath())) {
                        dmtn.remove(r);
                        files.remove(currFile);
                        if (null != openedFile) {
                            if (openedFile.equals(currFile)) {
                                closedOpenedDocument = true;
                                clearOpenedDocument();
                                setTitle(null);
                            }
                        }
                        break;
                    }
                }

            }
            int numOpened = files.size();
            if (1 == numOpened) {
                lblOpenedDocuments.setText("1 " + Bundle.getBundle().getString("tn.documentLoaded") + ":");
                dmtn.setUserObject(null);
            } else {
                lblOpenedDocuments
                        .setText(numOpened + " " + Bundle.getBundle().getString("tn.documentsLoaded") + ":");
                dmtn.setUserObject(null);
            }
            TreeModel tm = new DefaultTreeModel(dmtn);
            jtOpenedDocuments.setModel(tm);

            if (closedOpenedDocument && !files.isEmpty()) {
                File first = files.get(files.size() - 1);
                jtOpenedDocuments.setSelectionRow(0);
                ctrl.openDocument(first.getAbsolutePath());
                workspacePanel.setDocument(ctrl.getDocument());
                openedFile = first;
            }
        }
    }
}

From source file:view.MainWindow.java

public boolean loadPdf(File selectedFile, boolean showOpenDialog) {
    if (null == openedFile || !openedFile.equals(selectedFile)) {
        if (selectedFile.isFile() && selectedFile.exists()) {
            try {
                if (null == dmtn) {
                    lblOpenedDocuments.setText("0 " + Bundle.getBundle().getString("tn.documentsLoaded"));
                    dmtn = new DefaultMutableTreeNode(null);
                }/*from   w ww. ja v a 2  s .  c om*/
                boolean exists = false;
                for (int i = 0; i < dmtn.getChildCount(); i++) {
                    if (String.valueOf(dmtn.getChildAt(i)).equals(selectedFile.getAbsolutePath())) {
                        exists = true;

                        jtOpenedDocuments.setSelectionRow(i);
                        ctrl.openDocument(selectedFile.getAbsolutePath());
                        workspacePanel.setDocument(ctrl.getDocument());
                        openedFile = selectedFile;
                        break;
                    }
                }
                if (!exists) {
                    if (testPdf(selectedFile)) {
                        dmtn.insert(new DefaultMutableTreeNode(selectedFile), 0);
                        TreeModel tm = new DefaultTreeModel(dmtn);
                        jtOpenedDocuments.setModel(tm);
                        // jtOpenedDocuments.setSelectionRow(1);
                        int numOpened = dmtn.getChildCount();
                        if (1 == numOpened) {
                            lblOpenedDocuments
                                    .setText("1 " + Bundle.getBundle().getString("tn.documentLoaded") + ":");
                            dmtn.setUserObject(null);
                        } else {
                            lblOpenedDocuments.setText(
                                    numOpened + " " + Bundle.getBundle().getString("tn.documentsLoaded") + ":");
                            dmtn.setUserObject(null);
                        }

                        if (null == openedFile) {
                            jtOpenedDocuments.setSelectionRow(0);
                            jtOpenedDocuments.scrollRowToVisible(0);
                            ctrl.openDocument(selectedFile.getAbsolutePath());
                            workspacePanel.setDocument(ctrl.getDocument());
                            files.add(new File(selectedFile.getAbsolutePath()));
                            openedFile = selectedFile;
                            return true;

                        } else {
                            jtOpenedDocuments.setSelectionRow(1);
                            jtOpenedDocuments.scrollRowToVisible(1);
                            if (showOpenDialog) {
                                String msg = Bundle.getBundle().getString("msg.openNewOrKeepCurrent");
                                Object[] options = { Bundle.getBundle().getString("yes"),
                                        Bundle.getBundle().getString("opt.justAdd") };
                                int opt = JOptionPane.showOptionDialog(null, msg, "",
                                        JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, options,
                                        options[0]);
                                if (opt == JOptionPane.YES_OPTION) {
                                    jtOpenedDocuments.setSelectionRow(0);
                                    ctrl.openDocument(selectedFile.getAbsolutePath());
                                    workspacePanel.setDocument(ctrl.getDocument());
                                    openedFile = selectedFile;
                                }
                            }
                            files.add(new File(selectedFile.getAbsolutePath()));
                            return true;
                        }
                    } else {
                        errorList.add(selectedFile.getAbsolutePath());
                        showErrors();
                    }
                }
            } catch (Exception e) {
                controller.Logger.getLogger().addEntry(e);
            }
        }
    }
    return false;
}