List of usage examples for javax.swing JOptionPane NO_OPTION
int NO_OPTION
To view the source code for javax.swing JOptionPane NO_OPTION.
Click Source Link
From source file:edu.ku.brc.specify.tasks.InteractionsProcessor.java
/** * Asks where the source of the Loan Preps should come from. * @return the source enum/* w w w. j a v a 2 s . c om*/ */ protected ASK_TYPE askSourceOfPreps(final boolean hasInfoReqs, final boolean hasColObjRS, final T currPrepProvider) { String label; if (hasInfoReqs && hasColObjRS) { label = getResourceString("NEW_INTER_USE_RS_IR"); } else if (hasInfoReqs) { label = getResourceString("NEW_INTER_USE_IR"); } else { label = getResourceString("NEW_INTER_USE_RS"); } boolean isForAcc = isFor == forAcc; Object[] options = new Object[!isForAcc || (isForAcc && ((!hasInfoReqs && !hasColObjRS) || currPrepProvider != null)) ? 2 : 3]; Integer dosOpt = null; Integer rsOpt = null; Integer noneOpt = null; if (!isForAcc || currPrepProvider != null) { options[0] = label; options[1] = getResourceString("NEW_INTER_ENTER_CATNUM"); rsOpt = JOptionPane.YES_OPTION; dosOpt = JOptionPane.NO_OPTION; } else { if (options.length == 2) { options[0] = getResourceString("NEW_INTER_ENTER_CATNUM"); options[1] = getResourceString("NEW_INTER_EMPTY"); dosOpt = JOptionPane.YES_OPTION; noneOpt = JOptionPane.NO_OPTION; } else { options[0] = label; options[1] = getResourceString("NEW_INTER_ENTER_CATNUM"); options[2] = getResourceString("NEW_INTER_EMPTY"); rsOpt = JOptionPane.YES_OPTION; dosOpt = JOptionPane.NO_OPTION; noneOpt = JOptionPane.CANCEL_OPTION; } } int userChoice = JOptionPane.showOptionDialog(UIRegistry.getTopWindow(), getResourceString("NEW_INTER_CHOOSE_RSOPT"), getResourceString("NEW_INTER_CHOOSE_RSOPT_TITLE"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (userChoice == dosOpt) { return ASK_TYPE.EnterDataObjs; } else if (rsOpt != null && userChoice == rsOpt) { return ASK_TYPE.ChooseRS; } else if (noneOpt != null && userChoice == noneOpt) { return ASK_TYPE.None; } return ASK_TYPE.Cancel; }
From source file:net.pms.newgui.LanguageSelection.java
public void show() { if (PMS.isHeadless()) { // Can only get here during startup in headless mode, there's no way to trigger it from the GUI LOGGER.info(//www . java 2s . c o m "No language is configured and the language selection dialog is unavailable in headless mode"); LOGGER.info("Defaulting to OS locale {}", Locale.getDefault().getDisplayName()); PMS.setLocale(Locale.getDefault()); } else { pane = new JOptionPane(buildComponent(), JOptionPane.PLAIN_MESSAGE, JOptionPane.NO_OPTION, null, new JButton[] { applyButton, selectButton }, selectButton); pane.setComponentOrientation(ComponentOrientation.getOrientation(locale)); dialog = pane.createDialog(parentComponent, PMS.NAME); dialog.setModalityType(ModalityType.APPLICATION_MODAL); dialog.setIconImage(LooksFrame.readImageIcon("icon-32.png").getImage()); setStrings(); dialog.pack(); dialog.setLocationRelativeTo(parentComponent); dialog.setVisible(true); dialog.dispose(); if (pane.getValue() == null) { aborted = true; } else if (!((String) pane.getValue()).equals(PMS.getConfiguration().getLanguageRawString())) { if (rebootOnChange) { int response = JOptionPane.showConfirmDialog(parentComponent, String.format(buildString("Dialog.Restart", true), PMS.NAME, PMS.NAME), buildString("Dialog.Confirm"), JOptionPane.YES_NO_CANCEL_OPTION); if (response != JOptionPane.CANCEL_OPTION) { PMS.getConfiguration().setLanguage((String) pane.getValue()); if (response == JOptionPane.YES_OPTION) { try { PMS.getConfiguration().save(); } catch (ConfigurationException e) { LOGGER.error("Error while saving configuration: {}", e.getMessage()); LOGGER.trace("", e); } ProcessUtil.reboot(); } } } else { PMS.getConfiguration().setLanguage((String) pane.getValue()); } } } }
From source file:gda.gui.beans.SimpleBinaryBean.java
protected boolean executeCommand() { if (hasConfirmationDialog) { int dialogSelection = JOptionPane.showConfirmDialog(SimpleBinaryBean.this, dialogMessage, dialogTitle, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (dialogSelection == JOptionPane.NO_OPTION) return false; }/*from w w w.ja va2 s .c o m*/ return true; }
From source file:modelibra.swing.app.util.FileSelector.java
/** * Prompts a user to decide if the file should be replaced: yes or no. * // w ww . j a v a 2s . c o m * @param parentFrame * parent window * @param lang * language * @return <code>true</code> if a user chooses yes */ protected boolean replaceFile(JFrame parentFrame, NatLang lang) { // Custom button text Object[] options = { lang.getText("yes"), lang.getText("no") }; JOptionPane.setDefaultLocale(lang.getLocale()); int response = JOptionPane.showOptionDialog(parentFrame, // parent // frame lang.getText("replaceFile"), // message lang.getText("fileExists"), // title JOptionPane.YES_NO_OPTION, // option type JOptionPane.QUESTION_MESSAGE, // message type null, // don't use a custom icon options, // the titles of buttons options[0]); // default button title if (response == JOptionPane.NO_OPTION) { return false; } return true; }
From source file:ste.travian.gui.WorldController.java
/** * Shows the dialog to edit the map URL. */// w w w. j av a 2s . com public void updateWorld() { MapUrlPanel mapUrlPanel = new MapUrlPanel(); int result = JOptionPane.showOptionDialog(mainWindow, mapUrlPanel, mainWindow.getTitle(), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, new Object[] { "Download", "Cancel" }, null); if (result != JOptionPane.NO_OPTION) { try { load(mapUrlPanel.getUrl()); load(); } catch (Exception e) { mainWindow.error(e.getMessage(), e); } } }
From source file:VoteDialog.java
private JPanel createSimpleDialogBox() { final int numButtons = 4; JRadioButton[] radioButtons = new JRadioButton[numButtons]; final ButtonGroup group = new ButtonGroup(); JButton voteButton = null;/* ww w. j a va 2s . c om*/ final String defaultMessageCommand = "default"; final String yesNoCommand = "yesno"; final String yeahNahCommand = "yeahnah"; final String yncCommand = "ync"; radioButtons[0] = new JRadioButton("<html>Candidate 1: <font color=red>Sparky the Dog</font></html>"); radioButtons[0].setActionCommand(defaultMessageCommand); radioButtons[1] = new JRadioButton("<html>Candidate 2: <font color=green>Shady Sadie</font></html>"); radioButtons[1].setActionCommand(yesNoCommand); radioButtons[2] = new JRadioButton("<html>Candidate 3: <font color=blue>R.I.P. McDaniels</font></html>"); radioButtons[2].setActionCommand(yeahNahCommand); radioButtons[3] = new JRadioButton( "<html>Candidate 4: <font color=maroon>Duke the Java<font size=-2><sup>TM</sup></font size> Platform Mascot</font></html>"); radioButtons[3].setActionCommand(yncCommand); for (int i = 0; i < numButtons; i++) { group.add(radioButtons[i]); } // Select the first button by default. radioButtons[0].setSelected(true); voteButton = new JButton("Vote"); voteButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String command = group.getSelection().getActionCommand(); // ok dialog if (command == defaultMessageCommand) { JOptionPane.showMessageDialog(frame, "This candidate is a dog. Invalid vote."); // yes/no dialog } else if (command == yesNoCommand) { int n = JOptionPane.showConfirmDialog(frame, "This candidate is a convicted felon. \nDo you still want to vote for her?", "A Follow-up Question", JOptionPane.YES_NO_OPTION); if (n == JOptionPane.YES_OPTION) { setLabel("OK. Keep an eye on your wallet."); } else if (n == JOptionPane.NO_OPTION) { setLabel("Whew! Good choice."); } else { setLabel("It is your civic duty to cast your vote."); } // yes/no (with customized wording) } else if (command == yeahNahCommand) { Object[] options = { "Yes, please", "No, thanks" }; int n = JOptionPane.showOptionDialog(frame, "This candidate is deceased. \nDo you still want to vote for him?", "A Follow-up Question", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (n == JOptionPane.YES_OPTION) { setLabel("I hope you don't expect much from your candidate."); } else if (n == JOptionPane.NO_OPTION) { setLabel("Whew! Good choice."); } else { setLabel("It is your civic duty to cast your vote."); } // yes/no/cancel (with customized wording) } else if (command == yncCommand) { Object[] options = { "Yes!", "No, I'll pass", "Well, if I must" }; int n = JOptionPane.showOptionDialog(frame, "Duke is a cartoon mascot. \nDo you " + "still want to cast your vote?", "A Follow-up Question", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[2]); if (n == JOptionPane.YES_OPTION) { setLabel("Excellent choice."); } else if (n == JOptionPane.NO_OPTION) { setLabel("Whatever you say. It's your vote."); } else if (n == JOptionPane.CANCEL_OPTION) { setLabel("Well, I'm certainly not going to make you vote."); } else { setLabel("It is your civic duty to cast your vote."); } } return; } }); System.out.println("calling createPane"); return createPane(simpleDialogDesc + ":", radioButtons, voteButton); }
From source file:de.ipk_gatersleben.ag_nw.graffiti.plugins.gui.webstart.KgmlEdMain.java
/** * Constructs a new instance of the editor. *//* w w w .j a v a2s .co m*/ public KgmlEdMain(final boolean showMainFrame, String applicationName, String[] args) { // URL config, final ThreadSafeOptions tso = new ThreadSafeOptions(); SplashScreenInterface splashScreen = new DBEsplashScreen(applicationName, "", new Runnable() { public void run() { if (showMainFrame) { ClassLoader cl = this.getClass().getClassLoader(); String path = this.getClass().getPackage().getName().replace('.', '/'); ImageIcon icon = new ImageIcon(cl.getResource(path + "/ipklogo16x16_5.png")); final MainFrame mainFrame = MainFrame.getInstance(); mainFrame.setIconImage(icon.getImage()); Thread t = new Thread(new Runnable() { public void run() { long waitTime = 0; long start = System.currentTimeMillis(); do { if (ErrorMsg.getAppLoadingStatus() == ApplicationStatus.ADDONS_LOADED) break; try { Thread.sleep(50); } catch (InterruptedException e) { } waitTime = System.currentTimeMillis() - start; } while (waitTime < 2000); SplashScreenInterface ss = (SplashScreenInterface) tso.getParam(0, null); ss.setVisible(false); mainFrame.setVisible(true); } }, "wait for add-on initialization"); t.start(); } } }); tso.setParam(0, splashScreen); ClassLoader cl = this.getClass().getClassLoader(); String path = this.getClass().getPackage().getName().replace('.', '/'); ImageIcon icon = new ImageIcon(cl.getResource(path + "/ipklogo16x16_5.png")); ((DBEsplashScreen) splashScreen).setIconImage(icon.getImage()); splashScreen.setVisible(true); GravistoMainHelper.createApplicationSettingsFolder(splashScreen); if (!(new File(ReleaseInfo.getAppFolderWithFinalSep() + "license_kegg_accepted")).exists() && !(new File(ReleaseInfo.getAppFolderWithFinalSep() + "license_kegg_rejected")).exists()) { ReleaseInfo.setIsFirstRun(true); splashScreen.setVisible(false); splashScreen.setText("Request KEGG License Status"); JOptionPane.showMessageDialog(null, "<html><h3>KEGG License Status Evaluation</h3>" + "While " + DBEgravistoHelper.DBE_GRAVISTO_VERSION + " is available as a academic research tool at no cost to commercial and non-commercial users, for using<br>" + "KEGG related functions, it is necessary for all users to adhere to the KEGG license.<br>" + "For using " + DBEgravistoHelper.DBE_GRAVISTO_VERSION + " you need also be aware of information about licenses and conditions for<br>" + "usage, listed at the program info dialog and the " + DBEgravistoHelper.DBE_GRAVISTO_VERSION + " website (" + ReleaseInfo.getAppWebURL() + ").<br><br>" + DBEgravistoHelper.DBE_GRAVISTO_VERSION + " does not distribute information from KEGG but contains functionality for the online-access to information from KEGG wesite.<br><br>" + "<b>Before these functions are available to you, you should carefully read the following license information<br>" + "and decide if it is legit for you to use the KEGG related program functions. If you choose not to use the KEGG functions<br>" + "all other features of this application are still available and fully working.", DBEgravistoHelper.DBE_GRAVISTO_VERSION + " Program Features Initialization", JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(null, "<html><h3>KEGG License Status Evaluation</h3>" + MenuItemInfoDialog.getKEGGlibText(), DBEgravistoHelper.DBE_GRAVISTO_VERSION + " Program Features Initialization", JOptionPane.INFORMATION_MESSAGE); int result = JOptionPane.showConfirmDialog(null, "<html><h3>Enable KEGG functions?", DBEgravistoHelper.DBE_GRAVISTO_VERSION + " Program Features Initialization", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (result == JOptionPane.YES_OPTION) { try { new File(ReleaseInfo.getAppFolderWithFinalSep() + "license_kegg_accepted").createNewFile(); } catch (IOException e) { ErrorMsg.addErrorMessage(e); } } if (result == JOptionPane.NO_OPTION) { try { new File(ReleaseInfo.getAppFolderWithFinalSep() + "license_kegg_rejected").createNewFile(); } catch (IOException e) { ErrorMsg.addErrorMessage(e); } } if (result == JOptionPane.CANCEL_OPTION) { JOptionPane.showMessageDialog(null, "Startup aborted.", DBEgravistoHelper.DBE_GRAVISTO_VERSION + " Program Features Initialization", JOptionPane.INFORMATION_MESSAGE); System.exit(0); } splashScreen.setVisible(true); } GravistoMainHelper.initApplicationExt(args, splashScreen, cl, null, null); }
From source file:org.fhaes.FHRecorder.FireHistoryRecorder.java
/** * Closes the dialog but only after running necessary checks * to ensure user doesn't inadvertently loose data * /*from w w w . j a v a 2 s .c o m*/ */ private void closeAfterRunningChecks() { if (Controller.isModified()) { Object[] options = { "Save", "Close without saving", "Cancel" }; int n = JOptionPane.showOptionDialog(Controller.thePrimaryWindow, "Save changes to file before closing?", "Confirm", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[2]); if (n == JOptionPane.YES_OPTION) { Controller.save(); setVisible(false); } else if (n == JOptionPane.NO_OPTION) { Controller.setIsModified(false); Controller.setIsChangedSinceOpened(false); setVisible(false); } else if (n == JOptionPane.CANCEL_OPTION) { return; } } setVisible(false); }
From source file:components.DialogDemo.java
/** Creates the panel shown by the first tab. */ private JPanel createSimpleDialogBox() { final int numButtons = 4; JRadioButton[] radioButtons = new JRadioButton[numButtons]; final ButtonGroup group = new ButtonGroup(); JButton showItButton = null;/* ww w . j a v a 2 s . c o m*/ final String defaultMessageCommand = "default"; final String yesNoCommand = "yesno"; final String yeahNahCommand = "yeahnah"; final String yncCommand = "ync"; radioButtons[0] = new JRadioButton("OK (in the L&F's words)"); radioButtons[0].setActionCommand(defaultMessageCommand); radioButtons[1] = new JRadioButton("Yes/No (in the L&F's words)"); radioButtons[1].setActionCommand(yesNoCommand); radioButtons[2] = new JRadioButton("Yes/No " + "(in the programmer's words)"); radioButtons[2].setActionCommand(yeahNahCommand); radioButtons[3] = new JRadioButton("Yes/No/Cancel " + "(in the programmer's words)"); radioButtons[3].setActionCommand(yncCommand); 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(); //ok dialog if (command == defaultMessageCommand) { JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green."); //yes/no dialog } else if (command == yesNoCommand) { int n = JOptionPane.showConfirmDialog(frame, "Would you like green eggs and ham?", "An Inane Question", JOptionPane.YES_NO_OPTION); if (n == JOptionPane.YES_OPTION) { setLabel("Ewww!"); } else if (n == JOptionPane.NO_OPTION) { setLabel("Me neither!"); } else { setLabel("Come on -- tell me!"); } //yes/no (not in those words) } else if (command == yeahNahCommand) { Object[] options = { "Yes, please", "No way!" }; int n = JOptionPane.showOptionDialog(frame, "Would you like green eggs and ham?", "A Silly Question", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (n == JOptionPane.YES_OPTION) { setLabel("You're kidding!"); } else if (n == JOptionPane.NO_OPTION) { setLabel("I don't like them, either."); } else { setLabel("Come on -- 'fess up!"); } //yes/no/cancel (not in those words) } else if (command == yncCommand) { Object[] options = { "Yes, please", "No, thanks", "No eggs, no ham!" }; int n = JOptionPane.showOptionDialog(frame, "Would you like some green eggs to go " + "with that ham?", "A Silly Question", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[2]); if (n == JOptionPane.YES_OPTION) { setLabel("Here you go: green eggs and ham!"); } else if (n == JOptionPane.NO_OPTION) { setLabel("OK, just the ham, then."); } else if (n == JOptionPane.CANCEL_OPTION) { setLabel("Well, I'm certainly not going to eat them!"); } else { setLabel("Please tell me what you want!"); } } return; } }); return createPane(simpleDialogDesc + ":", radioButtons, showItButton); }
From source file:de.fhg.igd.mapviewer.server.file.FileTiler.java
/** * Load the command paths from the preferences or ask the user for them *//* www . j av a 2s .c om*/ private void loadCommandPaths() { String convert = pref.get(PREF_CONVERT, null); String identify = pref.get(PREF_IDENTIFY, null); JFileChooser commandChooser = new JFileChooser(); if (convert != null && identify != null) { if (JOptionPane.showConfirmDialog(null, "<html>Found paths to executables:<br/><b>" + convert + "<br/>" + identify + "</b><br/>Do you want to use this settings?</html>", "Paths to executables", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.NO_OPTION) { convert = null; identify = null; } } if (convert == null) { // ask for convert path convert = askForPath(commandChooser, new ContainsFileFilter("convert"), "Please select your convert executable"); } if (convert != null && identify == null) { // ask for identify path identify = askForPath(commandChooser, new ContainsFileFilter("identify"), "Please select your identify executable"); } if (convert == null) pref.remove(PREF_CONVERT); else pref.put(PREF_CONVERT, convert); if (identify == null) pref.remove(PREF_IDENTIFY); else pref.put(PREF_IDENTIFY, identify); convertPath = convert; identifyPath = identify; }