Example usage for javax.swing JOptionPane QUESTION_MESSAGE

List of usage examples for javax.swing JOptionPane QUESTION_MESSAGE

Introduction

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

Prototype

int QUESTION_MESSAGE

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

Click Source Link

Document

Used for questions.

Usage

From source file:com.ejie.uda.jsonI18nEditor.Editor.java

public void showAddLocaleDialog(ResourceType type) {
    String locale = "";
    while (locale != null && locale.isEmpty()) {
        locale = (String) JOptionPane.showInputDialog(this, MessageBundle.get("dialogs.locale.add.text"),
                MessageBundle.get("dialogs.locale.add.title", type.toString()), JOptionPane.QUESTION_MESSAGE);
        if (locale != null) {
            locale = locale.trim();//from  w  w w .ja v  a 2  s .  com
            //            Path path = Paths.get(resourcesDir.toString(), locale);
            Path path = resourcesDir;
            if (locale.isEmpty()) {
                //            if (locale.isEmpty() || Files.isDirectory(path)) {
                showError(MessageBundle.get("dialogs.locale.add.error.invalid"));
            } else {
                try {
                    Resource resource = Resources.create(type, path, this.bundle, locale);
                    setupResource(resource);
                    updateUI();
                } catch (IOException e) {
                    e.printStackTrace();
                    showError(MessageBundle.get("dialogs.locale.add.error.create"));
                }
            }
        }
    }
}

From source file:com.sshtools.j2ssh.authentication.UserGridCredential.java

private static GSSCredential chooseCert(int proxyType, int lifetimeHours, SshConnectionProperties props)
        throws IOException, IllegalArgumentException, IllegalStateException {
    String dProfile = PreferencesStore.get(SshTerminalPanel.PREF_BROWSER_PROFILE, null);
    String dDN = PreferencesStore.get(SshTerminalPanel.PREF_BROWSER_DN, null);
    if (props instanceof SshToolsConnectionProfile) {
        SshToolsConnectionProfile profile = (SshToolsConnectionProfile) props;
        dProfile = profile.getApplicationProperty(SshTerminalPanel.PREF_BROWSER_PROFILE, dProfile);
        dDN = profile.getApplicationProperty(SshTerminalPanel.PREF_BROWSER_DN, dDN);
    }//from w w  w .ja  v  a2  s . c  om

    String profile = Browser.getCurrentBrowser();
    if (profile == null) {
        String profiles[] = Browser.getBrowserList();
        if (profiles == null)
            return null;
        if (profiles.length == 0) {
            JOptionPane.showMessageDialog(props.getWindow(), "No browsers found", "GSI-SSHTerm Authentication",
                    JOptionPane.ERROR_MESSAGE);
            return null;
        }
        if (profiles.length == 1) {
            Browser.setBrowser(profiles[0]); //user chooses profile.
        } else {
            boolean chosen = false;
            if (dProfile != null) {
                for (String p : profiles) {
                    if (p.equals(dProfile)) {
                        chosen = true;
                        Browser.setBrowser(p);
                    }
                }
            }
            if (!chosen) {
                JComboBox combo = new JComboBox(profiles);
                int ret = JOptionPane.showOptionDialog(props.getWindow(), "Please choose browser to use:",
                        "Grid Authentication", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null,
                        new Object[] { combo, "OK" }, null);
                if (ret == JOptionPane.CLOSED_OPTION)
                    new IOException("Canceled by user.");
                Browser.setBrowser(profiles[combo.getSelectedIndex()]); //user chooses profile.
            }
        }
        profile = Browser.getCurrentBrowser();
    }
    String dnlist[] = null;
    try {
        dnlist = Browser.getDNlist(new PasswordPrompt(props));
    } catch (IOException e) {
        e.printStackTrace();
        errorReport(props.getWindow(), "Could not access keystore in profile: " + profile, e);
        log.debug("Could not access keystore in profile: " + profile + " : " + e);
    } catch (KeyStoreException e) {
        e.printStackTrace();
        errorReport(props.getWindow(), "Could not access keystore in profile: " + profile, e);
        log.debug("Could not access keystore in profile: " + profile + " : " + e);
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
        errorReport(props.getWindow(), "Could not access keystore in profile: " + profile, e);
        log.debug("Could not access keystore in profile: " + profile + " : " + e);
    } catch (CertificateException e) {
        e.printStackTrace();
        errorReport(props.getWindow(), "Could not access keystore in profile: " + profile, e);
        log.debug("Could not access keystore in profile: " + profile + " : " + e);
    } catch (InvalidAlgorithmParameterException e) {
        e.printStackTrace();
        errorReport(props.getWindow(), "Could not access keystore in profile: " + profile, e);
        log.debug("Could not access keystore in profile: " + profile + " : " + e);
    } catch (javax.security.auth.login.FailedLoginException e) {
        JOptionPane.showMessageDialog(props.getWindow(), e.getMessage(), "Incorrect Password",
                JOptionPane.ERROR_MESSAGE);
        return null;
    } catch (GeneralSecurityException e) {
        if (e.getMessage().indexOf("version>=1.5") >= 0) {
            JOptionPane.showMessageDialog(props.getWindow(), e.getMessage(), "GSI-SSHTerm Authentication",
                    JOptionPane.ERROR_MESSAGE);
        } else {
            e.printStackTrace();
            errorReport(props.getWindow(), "Could not access keystore in profile: " + profile, e);
            log.debug("Could not access keystore in profile: " + profile + " : " + e);
        }
    }
    if (dnlist == null)
        return null;
    int index = -1;
    if (dnlist.length == 0) {
        JOptionPane.showMessageDialog(props.getWindow(), "No Certificates found", "GSI-SSHTerm Authentication",
                JOptionPane.ERROR_MESSAGE);
        return null;
    }
    if (dnlist.length == 1) {
        index = 0;
    } else {
        if (dDN != null) {
            for (int i = 0; i < dnlist.length; i++) {
                if (dnlist[i].equals(dDN)) {
                    index = i;
                }
            }
        }
        if (index == -1) {
            JComboBox dnCombo = new JComboBox(dnlist);

            int ret = JOptionPane.showOptionDialog(props.getWindow(), "Please choose certificate to use:",
                    "GSI-SSHTerm Authentication", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null,
                    new Object[] { dnCombo, "OK" }, null);
            if (ret == JOptionPane.CLOSED_OPTION)
                new IOException("Canceled by user.");
            index = dnCombo.getSelectedIndex();
        }
    }
    try {
        GSSCredential gssproxy = Browser.getGridProxy(dnlist[index], proxyType, lifetimeHours);

        if (SAVE_BROWSER_PROXY) {
            GlobusCredential proxy = ((GlobusGSSCredentialImpl) gssproxy).getGlobusCredential();
            ProxyHelper.saveProxy(proxy, props);
        }
        return gssproxy;
    } catch (GeneralSecurityException e) {
        e.printStackTrace();
        errorReport(props.getWindow(), "Could not load certificate from profile: " + profile, e);
        log.debug("Could not load certificate from browser: " + e);
    } catch (GlobusCredentialException e) {
        e.printStackTrace();
        errorReport(props.getWindow(), "Could not load certificate from profile: " + profile, e);
        log.debug("Could not load certificate from browser: " + e);
    } catch (GSSException e) {
        e.printStackTrace();
        errorReport(props.getWindow(), "Could not load certificate from profile: " + profile, e);
        log.debug("Could not load certificate from browser: " + e);
    }
    return null;
}

From source file:components.DialogDemo.java

private JPanel createIconDialogBox() {
    JButton showItButton = null;/*w  w w.  ja  v  a 2s . c o  m*/

    final int numButtons = 6;
    JRadioButton[] radioButtons = new JRadioButton[numButtons];
    final ButtonGroup group = new ButtonGroup();

    final String plainCommand = "plain";
    final String infoCommand = "info";
    final String questionCommand = "question";
    final String errorCommand = "error";
    final String warningCommand = "warning";
    final String customCommand = "custom";

    radioButtons[0] = new JRadioButton("Plain (no icon)");
    radioButtons[0].setActionCommand(plainCommand);

    radioButtons[1] = new JRadioButton("Information icon");
    radioButtons[1].setActionCommand(infoCommand);

    radioButtons[2] = new JRadioButton("Question icon");
    radioButtons[2].setActionCommand(questionCommand);

    radioButtons[3] = new JRadioButton("Error icon");
    radioButtons[3].setActionCommand(errorCommand);

    radioButtons[4] = new JRadioButton("Warning icon");
    radioButtons[4].setActionCommand(warningCommand);

    radioButtons[5] = new JRadioButton("Custom icon");
    radioButtons[5].setActionCommand(customCommand);

    for (int i = 0; i < numButtons; i++) {
        group.add(radioButtons[i]);
    }
    radioButtons[0].setSelected(true);

    showItButton = new JButton("Show it!");
    showItButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String command = group.getSelection().getActionCommand();

            //no icon
            if (command == plainCommand) {
                JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "A plain message",
                        JOptionPane.PLAIN_MESSAGE);
                //information icon
            } else if (command == infoCommand) {
                JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.",
                        "Inane informational dialog", JOptionPane.INFORMATION_MESSAGE);

                //XXX: It doesn't make sense to make a question with
                //XXX: only one button.
                //XXX: See "Yes/No (but not in those words)" for a better solution.
                //question icon
            } else if (command == questionCommand) {
                JOptionPane.showMessageDialog(frame,
                        "You shouldn't use a message dialog " + "(like this)\n" + "for a question, OK?",
                        "Inane question", JOptionPane.QUESTION_MESSAGE);
                //error icon
            } else if (command == errorCommand) {
                JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "Inane error",
                        JOptionPane.ERROR_MESSAGE);
                //warning icon
            } else if (command == warningCommand) {
                JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "Inane warning",
                        JOptionPane.WARNING_MESSAGE);
                //custom icon
            } else if (command == customCommand) {
                JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "Inane custom dialog",
                        JOptionPane.INFORMATION_MESSAGE, icon);
            }
        }
    });

    return create2ColPane(iconDesc + ":", radioButtons, showItButton);
}

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

/**
 * Bring up a simple dialog to allow the user to add a task.
 *//* w w  w.ja  v  a  2s .co m*/
public void showAddTaskDialog() {
    String taskName = JOptionPane.showInputDialog(this, "New Task Name", "Add Task",
            JOptionPane.QUESTION_MESSAGE);

    if (taskName != null) {
        getTimelordData().addTask(taskName);
    }
}

From source file:com.jvms.i18neditor.editor.Editor.java

public void showAddLocaleDialog() {
    String localeString = "";
    Path path = project.getPath();
    ResourceType type = project.getResourceType();
    while (localeString != null && localeString.isEmpty()) {
        localeString = Dialogs.showInputDialog(this, MessageBundle.get("dialogs.locale.add.title", type),
                MessageBundle.get("dialogs.locale.add.text"), JOptionPane.QUESTION_MESSAGE);
        if (localeString != null) {
            localeString = localeString.trim();
            if (localeString.isEmpty()) {
                showError(MessageBundle.get("dialogs.locale.add.error.invalid"));
            } else {
                try {
                    Locale locale = LocaleUtils.toLocale(localeString);
                    Resource resource = Resources.create(path, type, Optional.of(locale),
                            project.getResourceName());
                    addResource(resource);
                } catch (IOException e) {
                    log.error("Error creating new locale", e);
                    showError(MessageBundle.get("dialogs.locale.add.error.create"));
                }/* w  w  w  .  j av a2  s.co m*/
            }
        }
    }
}

From source file:gdt.jgui.base.JPropertyPanel.java

/**
 * Response on menu action/*from   w  w  w.j a v  a  2  s .co m*/
 * @param console main console
 * @param locator$ the locator string.
 */
@Override
public void response(JMainConsole console, String locator$) {
    try {
        //System.out.println("PropertyPanel:response:locator="+locator$);
        Properties locator = Locator.toProperties(locator$);
        String action$ = locator.getProperty(JRequester.REQUESTER_ACTION);
        String entihome$ = locator.getProperty(Entigrator.ENTIHOME);
        Entigrator entigrator = console.getEntigrator(entihome$);
        if (ACTION_ADD_PROPERTY.equals(action$)) {
            String text$ = locator.getProperty(JTextEditor.TEXT);
            //   System.out.println("PropertyPanel:response:property="+text$);
            if (text$ != null)
                entigrator.indx_addPropertyName(text$);
            JDesignPanel dp = new JDesignPanel();
            String dpLocator$ = dp.getLocator();
            dpLocator$ = Locator.append(dpLocator$, Entigrator.ENTIHOME, entihome$);
            dpLocator$ = Locator.append(dpLocator$, JDesignPanel.PROPERTY_NAME, text$);
            JConsoleHandler.execute(console, dpLocator$);
            return;
        }
        if (ACTION_EDIT_PROPERTY.equals(action$)) {
            String text$ = locator.getProperty(JTextEditor.TEXT);
            String propertyName$ = locator.getProperty(JDesignPanel.PROPERTY_NAME);
            //   System.out.println("PropertyPanel:response:set  property name ="+propertyName$+" new="+text$);
            if (text$ != null)
                entigrator.prp_editPropertyName(propertyName$, text$);

            JDesignPanel dp = new JDesignPanel();
            String dpLocator$ = dp.getLocator();
            dpLocator$ = Locator.append(dpLocator$, Entigrator.ENTIHOME, entihome$);
            dpLocator$ = Locator.append(dpLocator$, JDesignPanel.PROPERTY_NAME, text$);
            JConsoleHandler.execute(console, dpLocator$);
            return;
        }
        if (ACTION_CLEAR_PROPERTIES.equals(action$)) {
            //System.out.println("PropertyPanel:response:action="+action$);
            int response = JOptionPane.showConfirmDialog(console.getContentPanel(),
                    "Delete unused properties ?", "Confirm", JOptionPane.YES_NO_OPTION,
                    JOptionPane.QUESTION_MESSAGE);
            if (response == JOptionPane.YES_OPTION) {
                entigrator.prp_deleteWrongEntries();
                JDesignPanel dp = new JDesignPanel();
                String dpLocator$ = dp.getLocator();
                dpLocator$ = Locator.append(dpLocator$, Entigrator.ENTIHOME, entihome$);
                JConsoleHandler.execute(console, dpLocator$);
                return;
            }
        }
    } catch (Exception e) {
        Logger.getLogger(getClass().getName()).severe(e.toString());
    }
}

From source file:DialogDemo.java

private JPanel createIconDialogBox() {
    JButton showItButton = null;/*from ww  w  .  j  a  v a  2 s  . co m*/

    final int numButtons = 6;
    JRadioButton[] radioButtons = new JRadioButton[numButtons];
    final ButtonGroup group = new ButtonGroup();

    final String plainCommand = "plain";
    final String infoCommand = "info";
    final String questionCommand = "question";
    final String errorCommand = "error";
    final String warningCommand = "warning";
    final String customCommand = "custom";

    radioButtons[0] = new JRadioButton("Plain (no icon)");
    radioButtons[0].setActionCommand(plainCommand);

    radioButtons[1] = new JRadioButton("Information icon");
    radioButtons[1].setActionCommand(infoCommand);

    radioButtons[2] = new JRadioButton("Question icon");
    radioButtons[2].setActionCommand(questionCommand);

    radioButtons[3] = new JRadioButton("Error icon");
    radioButtons[3].setActionCommand(errorCommand);

    radioButtons[4] = new JRadioButton("Warning icon");
    radioButtons[4].setActionCommand(warningCommand);

    radioButtons[5] = new JRadioButton("Custom icon");
    radioButtons[5].setActionCommand(customCommand);

    for (int i = 0; i < numButtons; i++) {
        group.add(radioButtons[i]);
    }
    radioButtons[0].setSelected(true);

    showItButton = new JButton("Show it!");
    showItButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String command = group.getSelection().getActionCommand();

            // no icon
            if (command == plainCommand) {
                JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "A plain message",
                        JOptionPane.PLAIN_MESSAGE);
                // information icon
            } else if (command == infoCommand) {
                JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.",
                        "Inane informational dialog", JOptionPane.INFORMATION_MESSAGE);

                // XXX: It doesn't make sense to make a question with
                // XXX: only one button.
                // XXX: See "Yes/No (but not in those words)" for a better solution.
                // question icon
            } else if (command == questionCommand) {
                JOptionPane.showMessageDialog(frame,
                        "You shouldn't use a message dialog " + "(like this)\n" + "for a question, OK?",
                        "Inane question", JOptionPane.QUESTION_MESSAGE);
                // error icon
            } else if (command == errorCommand) {
                JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "Inane error",
                        JOptionPane.ERROR_MESSAGE);
                // warning icon
            } else if (command == warningCommand) {
                JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "Inane warning",
                        JOptionPane.WARNING_MESSAGE);
                // custom icon
            } else if (command == customCommand) {
                JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "Inane custom dialog",
                        JOptionPane.INFORMATION_MESSAGE, icon);
            }
        }
    });

    return create2ColPane(iconDesc + ":", radioButtons, showItButton);
}

From source file:gdt.jgui.entity.query.JQueryPanel.java

/**
 * Get the context menu./*from  www  .  j a va  2s.c o m*/
 * @return the context menu.
 */
@Override
public JMenu getContextMenu() {
    menu = new JMenu("Context");
    menu.addMenuListener(new MenuListener() {
        @Override
        public void menuSelected(MenuEvent e) {
            menu.removeAll();
            //            System.out.println("BookmarksEditor:getConextMenu:menu selected");
            JMenuItem selectItem = new JMenuItem("Select");
            selectItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    showHeader();
                    showContent();
                }
            });
            menu.add(selectItem);
            JMenuItem clearHeader = new JMenuItem("Clear all");
            clearHeader.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    clearHeader();
                    showHeader();
                    showContent();
                }
            });
            menu.add(clearHeader);
            Entigrator entigrator = console.getEntigrator(entihome$);
            Sack query = entigrator.getEntityAtKey(entityKey$);
            if (query.getElementItem("parameter", "noreset") == null) {
                JMenuItem resetItem = new JMenuItem("Reset");
                resetItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        int response = JOptionPane.showConfirmDialog(console.getContentPanel(),
                                "Reset source to default ?", "Confirm", JOptionPane.YES_NO_OPTION,
                                JOptionPane.QUESTION_MESSAGE);
                        if (response == JOptionPane.YES_OPTION)
                            reset();
                    }
                });
                menu.add(resetItem);
            }
            JMenuItem folderItem = new JMenuItem("Open folder");
            folderItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    try {
                        File file = new File(entihome$ + "/" + entityKey$);
                        Desktop.getDesktop().open(file);
                    } catch (Exception ee) {
                        Logger.getLogger(getClass().getName()).info(ee.toString());
                    }
                }
            });
            menu.add(folderItem);

            menu.addSeparator();
            JMenuItem addHeader = new JMenuItem("Add column");
            addHeader.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    addHeader();
                }
            });
            menu.add(addHeader);
            JMenuItem removeColumn = new JMenuItem("Remove column ");
            removeColumn.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    removeColumn();
                }
            });
            menu.add(removeColumn);
            ListSelectionModel lsm = table.getSelectionModel();
            if (!lsm.isSelectionEmpty()) {
                JMenuItem excludeRows = new JMenuItem("Exclude rows ");
                excludeRows.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        Entigrator entigrator = console.getEntigrator(entihome$);
                        Sack query = entigrator.getEntityAtKey(entityKey$);
                        if (!query.existsElement("exclude"))
                            query.createElement("exclude");
                        //else
                        //   query.clearElement("exclude");
                        ListSelectionModel lsm = table.getSelectionModel();
                        int minIndex = lsm.getMinSelectionIndex();
                        int maxIndex = lsm.getMaxSelectionIndex();
                        for (int i = minIndex; i <= maxIndex; i++) {
                            if (lsm.isSelectedIndex(i)) {
                                System.out.println("JQueryPanel:exclude rows:label=" + table.getValueAt(i, 1));
                                query.putElementItem("exclude",
                                        new Core(null, (String) table.getValueAt(i, 1), null));
                            }
                        }
                        entigrator.save(query);
                        showHeader();
                        showContent();
                    }
                });
                menu.add(excludeRows);
            }
        }

        @Override
        public void menuDeselected(MenuEvent e) {
        }

        @Override
        public void menuCanceled(MenuEvent e) {
        }
    });
    return menu;
}

From source file:charitypledge.Pledge.java

private void ExitButtonActionPerformed(java.awt.event.ActionEvent evt) {
    JFrame frame = new JFrame();
    int confirm = JOptionPane.showOptionDialog(frame, "Are You Sure to Close this Application?",
            "Exit Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
    if (confirm == JOptionPane.YES_OPTION) {
        System.exit(0);//from w  w w  . j  a  v  a 2s . c  om
    }
}

From source file:marytts.tools.voiceimport.DatabaseImportMain.java

protected void closeGUI() {
    // This doesn't work because Java cannot close the X11 connection, see
    // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4420885
    int answer = JOptionPane.showOptionDialog(this,
            "Do you want to close this GUI?\n\n"
                    + "The components that are currently running will continue to run,\n"
                    + "but you will not be able to save settings or select/deselect\n" + "components to run.\n"
                    + "This may be useful when running this tool using 'nohup' on a server\n"
                    + "because it allows you to log off without stopping the process.",
            "Really close GUI?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
    if (answer == JOptionPane.YES_OPTION) {
        this.setVisible(false);
        this.dispose();
    }/*from   w  w  w.  j  av  a2s .  c  o  m*/
}