List of usage examples for javax.swing JOptionPane QUESTION_MESSAGE
int QUESTION_MESSAGE
To view the source code for javax.swing JOptionPane QUESTION_MESSAGE.
Click Source Link
From source file:edu.ku.brc.helpers.EMailHelper.java
/** * Asks for a username and password./*from w ww . ja v a2 s.com*/ * @param topframe the parent frame * @return the list of user[index 1] and password[index 2], or 'null' if cancel was pressed */ public static ArrayList<String> askForUserAndPassword(final Frame topframe) { ArrayList<String> userAndPass = new ArrayList<String>(); //get remote prefs AppPreferences remotePrefs = AppPreferences.getRemote(); //get remote password String remoteUsername = remotePrefs.get("settings.email.username", null); //$NON-NLS-1$ PanelBuilder builder = new PanelBuilder(new FormLayout("p,2px,p", "p,2px,p,2px,p")); //$NON-NLS-1$ //$NON-NLS-2$ CellConstraints cc = new CellConstraints(); JLabel plabel = createI18NFormLabel("EMailHelper.PASSWORD"); //$NON-NLS-1$ //$NON-NLS-2$ JLabel ulabel = createI18NFormLabel("EMailHelper.USERNAME"); //$NON-NLS-1$ //$NON-NLS-2$ JPasswordField passField = createPasswordField(25); JTextField userField = createTextField(remoteUsername, 25); JCheckBox savePassword = createCheckBox(getResourceString("EMailHelper.SAVE_PASSWORD")); //$NON-NLS-1$ builder.add(ulabel, cc.xy(1, 1)); builder.add(userField, cc.xy(3, 1)); builder.add(plabel, cc.xy(1, 3)); builder.add(passField, cc.xy(3, 3)); builder.add(savePassword, cc.xy(3, 5)); Integer option = JOptionPane.showConfirmDialog(topframe, builder.getPanel(), getResourceString("EMailHelper.PASSWORD_TITLE"), JOptionPane.OK_CANCEL_OPTION, //$NON-NLS-1$ JOptionPane.QUESTION_MESSAGE); String passwordText = new String(passField.getPassword()); String userText = new String(userField.getText()); if (savePassword.isSelected()) { if (StringUtils.isNotEmpty(passwordText)) { remotePrefs.put("settings.email.password", Encryption.encrypt(passwordText)); //$NON-NLS-1$ } } if (option == JOptionPane.CANCEL_OPTION) { return null; } //else userAndPass.add(0, userText); userAndPass.add(1, passwordText); return userAndPass; }
From source file:net.sf.jabref.gui.exporter.SaveDatabaseAction.java
/** * Check whether or not the external database has been modified. If so need to alert the user to accept external updates prior to * saving the database. This is necessary to avoid overwriting other users work when using a multiuser database file. * * @return true if the external database file has been modified and the user must choose to accept the changes and false if no modifications * were found or there is no requested protection for the database file. *///from w w w . ja va 2 s. c o m private boolean checkExternalModification() { // Check for external modifications: if (panel.isUpdatedExternally() || Globals.getFileUpdateMonitor().hasBeenModified(panel.getFileMonitorHandle())) { String[] opts = new String[] { Localization.lang("Review changes"), Localization.lang("Save"), Localization.lang("Cancel") }; int answer = JOptionPane.showOptionDialog(panel.frame(), Localization.lang("File has been updated externally. " + "What do you want to do?"), Localization.lang("File updated externally"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, opts, opts[0]); if (answer == JOptionPane.CANCEL_OPTION) { canceled = true; return true; } else if (answer == JOptionPane.YES_OPTION) { canceled = true; JabRefExecutorService.INSTANCE.execute(() -> { if (!FileBasedLock.waitForFileLock(panel.getBibDatabaseContext().getDatabaseFile().toPath(), 10)) { // TODO: GUI handling of the situation when the externally modified file keeps being locked. LOGGER.error("File locked, this will be trouble."); } ChangeScanner scanner = new ChangeScanner(panel.frame(), panel, panel.getBibDatabaseContext().getDatabaseFile()); JabRefExecutorService.INSTANCE.executeWithLowPriorityInOwnThreadAndWait(scanner); if (scanner.changesFound()) { scanner.displayResult(resolved -> { if (resolved) { panel.setUpdatedExternally(false); SwingUtilities.invokeLater(() -> panel.getSidePaneManager().hide("fileUpdate")); } else { canceled = true; } }); } }); return true; } else { // User indicated to store anyway. if (panel.getBibDatabaseContext().getMetaData().isProtected()) { JOptionPane.showMessageDialog(frame, Localization .lang("Database is protected. Cannot save until external changes have been reviewed."), Localization.lang("Protected database"), JOptionPane.ERROR_MESSAGE); canceled = true; } else { panel.setUpdatedExternally(false); panel.getSidePaneManager().hide("fileUpdate"); } } } // Return false as either no external database file modifications have been found or overwrite is requested any way return false; }
From source file:Forms.CreateGearForm.java
private void showLoadErrorDialog() { Object[] options = { "OK" }; int answer = JOptionPane.showOptionDialog(SwingUtilities.getWindowAncestor(MasterPanel), "There was a problem loading your Gear Spec. Please try again.", "Lint Error", JOptionPane.OK_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); }
From source file:net.chaosserver.timelord.swingui.CommonTaskPanel.java
/** * Bring up a single dialog to allow a user to unhide a task. *//*from w ww .j a v a2 s . co m*/ public void showUnhideTaskDialog() { List<TimelordTask> hiddenTasks = getTimelordData().getHiddenTasks(); TimelordTask timelordTask = (TimelordTask) JOptionPane.showInputDialog(this, "Unhide Task", "Unhide Task", JOptionPane.QUESTION_MESSAGE, null, hiddenTasks.toArray(), null); if (timelordTask != null) { timelordTask.setHidden(false); } }
From source file:com.ejie.uda.jsonI18nEditor.Editor.java
public void showDuplicateTranslationDialog(String key) { String newKey = ""; while (newKey != null && newKey.isEmpty()) { newKey = (String) JOptionPane.showInputDialog(this, MessageBundle.get("dialogs.translation.duplicate.text"), MessageBundle.get("dialogs.translation.duplicate.title"), JOptionPane.QUESTION_MESSAGE, null, null, key);//from w ww . jav a 2 s . c o m if (newKey != null) { newKey = newKey.trim(); if (!TranslationKeys.isValid(newKey)) { showError(MessageBundle.get("dialogs.translation.duplicate.error")); } else { TranslationTreeNode newNode = translationTree.getNodeByKey(newKey); TranslationTreeNode oldNode = translationTree.getNodeByKey(key); if (newNode != null) { boolean isReplace = newNode.isLeaf() || oldNode.isLeaf(); boolean confirm = showConfirmation(MessageBundle.get("dialogs.translation.conflict.title"), MessageBundle.get( "dialogs.translation.conflict.text." + (isReplace ? "replace" : "merge"))); if (confirm) { duplicateTranslationKey(key, newKey); } } else { duplicateTranslationKey(key, newKey); } } } } }
From source file:com.qawaa.gui.EventWebScanGUI.java
/** * ???//from w w w . ja v a 2 s .co m */ private void windowsClosed() { if (RUNNING) { int response = JOptionPane.showConfirmDialog(null, CONTEXT.getMessage("gobal.quit.dialog.msg", null, Locale.CHINA), CONTEXT.getMessage("gobal.quit.dialog.title", null, Locale.CHINA), JOptionPane.YES_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) { System.exit(0); } } else { System.exit(0); } }
From source file:de.huxhorn.lilith.swing.preferences.PreferencesDialog.java
public void reinitializeGroovyClipboardFormatters() { String dialogTitle = "Reinitialize example groovy clipboard formatters?"; String message = "This overwrites all example groovy clipboard formatters. Other clipboard formatters are not changed!\nReinitialize example groovy clipboard formatters right now?"; int result = JOptionPane.showConfirmDialog(this, message, dialogTitle, JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); // TODO: add "Show in Finder/Explorer" button if running on Mac/Windows if (JOptionPane.OK_OPTION != result) { return;/*from ww w .j ava 2s. c om*/ } applicationPreferences.installExampleClipboardFormatters(); }
From source file:gdt.jgui.entity.edge.JBondsPanel.java
/** * Get the context menu./*from w w w . j a v a2s. c o m*/ * @return the context menu. */ @Override public JMenu getContextMenu() { menu = super.getContextMenu(); int cnt = menu.getItemCount(); mia = new JMenuItem[cnt]; for (int i = 0; i < cnt; i++) mia[i] = menu.getItem(i); menu.addMenuListener(new MenuListener() { @Override public void menuSelected(MenuEvent e) { //System.out.println("WeblinkPanel:getConextMenu:menu selected"); menu.removeAll(); if (mia != null) { for (JMenuItem mi : mia) menu.add(mi); menu.addSeparator(); } if (hasSelectedItems()) { JMenuItem deleteItem = new JMenuItem("Delete"); deleteItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int response = JOptionPane.showConfirmDialog(console.getContentPanel(), "Delete ?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) { String[] sa = JBondsPanel.this.listSelectedItems(); if (sa == null) return; for (String s : sa) { // System.out.println("JBondsPanel:delete:s="+s); if (isGraphEntity()) removeBondEntry(s); else if (isEdgeEntity()) removeBond(console, s); else if (isDetailEntity()) { System.out.println("JBondsPanel:delete detail:"); Entigrator entigrator = console.getEntigrator(entihome$); BondDetailHandler.deleteDetail(entigrator, s); } } close(); JBondsPanel bp = new JBondsPanel(); String bpLocator$ = bp.getLocator(); bpLocator$ = Locator.append(bpLocator$, Entigrator.ENTIHOME, entihome$); bpLocator$ = Locator.append(bpLocator$, EntityHandler.ENTITY_KEY, entityKey$); JConsoleHandler.execute(console, bpLocator$); } } }); menu.add(deleteItem); JMenuItem copyItem = new JMenuItem("Copy"); copyItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String[] sa = JBondsPanel.this.listSelectedItems(); if (sa == null) return; for (String s : sa) { console.clipboard.putString(s); } } }); menu.add(copyItem); menu.addSeparator(); } if (isEdgeEntity()) { JMenuItem newItem = new JMenuItem("New"); newItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //System.out.println("JBondsPanel:new:"+locator$); Entigrator entigrator = console.getEntigrator(entihome$); Sack entity = entigrator.getEntityAtKey(entityKey$); if (!entity.existsElement("bond")) entity.createElement("bond"); String bondKey$ = Identity.key(); entity.putElementItem("bond", new Core(null, bondKey$, null)); // String icon$=Support.readHandlerIcon(JEntitiesPanel.class, "globe.png"); entigrator.save(entity); // JBondsPanel.this.getPanel().removeAll(); close(); JBondsPanel bp = new JBondsPanel(); String bpLocator$ = bp.getLocator(); bpLocator$ = Locator.append(bpLocator$, Entigrator.ENTIHOME, entihome$); bpLocator$ = Locator.append(bpLocator$, EntityHandler.ENTITY_KEY, entityKey$); //bpLocator$=Locator.append(bpLocator$, BaseHandler.HANDLER_METHOD,"instantiate"); JConsoleHandler.execute(console, bpLocator$); } }); menu.add(newItem); } if (isGraphEntity()) { JMenuItem showItem = new JMenuItem("Show"); showItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { JGraphRenderer gr = new JGraphRenderer(); String grLocator$ = gr.getLocator(); grLocator$ = Locator.append(grLocator$, Entigrator.ENTIHOME, entihome$); grLocator$ = Locator.append(grLocator$, EntityHandler.ENTITY_KEY, entityKey$); JConsoleHandler.execute(console, grLocator$); } catch (Exception ee) { Logger.getLogger(JGraphRenderer.class.getName()).info(ee.toString()); } } }); menu.add(showItem); if (hasBondsToPaste()) { JMenuItem pasteItem = new JMenuItem("Paste"); pasteItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { pasteBonds(); JBondsPanel bp = new JBondsPanel(); String bpLocator$ = bp.getLocator(); bpLocator$ = Locator.append(bpLocator$, Entigrator.ENTIHOME, entihome$); bpLocator$ = Locator.append(bpLocator$, EntityHandler.ENTITY_KEY, entityKey$); JConsoleHandler.execute(console, bpLocator$); } }); menu.add(pasteItem); } } JMenuItem doneItem = new JMenuItem("Done"); doneItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (requesterResponseLocator$ != null) { try { byte[] ba = Base64.decodeBase64(requesterResponseLocator$); String responseLocator$ = new String(ba, "UTF-8"); JConsoleHandler.execute(console, responseLocator$); } catch (Exception ee) { Logger.getLogger(JBondsPanel.class.getName()).severe(ee.toString()); } } else console.back(); } }); menu.add(doneItem); menu.addSeparator(); JMenuItem sortInNode = new JMenuItem("Sort in node"); sortInNode.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { selectMode$ = SELECT_MODE_IN; JItemPanel[] ipa = getItems(); Entigrator entigrator = console.getEntigrator(entihome$); InNodeComparator inc = new InNodeComparator(); inc.entigrator = entigrator; ArrayList<JItemPanel> ipl = new ArrayList<JItemPanel>(Arrays.asList(ipa)); Collections.sort(ipl, inc); panel.removeAll(); // System.out.println("JBondsPanel:sort in node:ipl="+ipl.size()); if (ipa != null) for (JItemPanel ip : ipl) { panel.add(ip); } revalidate(); repaint(); Sack entity = entigrator.getEntityAtKey(entityKey$); if (!entity.existsElement("parameter")) entity.createElement("parameter"); entity.putElementItem("parameter", new Core(null, SELECT_MODE, selectMode$)); entigrator.save(entity); } catch (Exception ee) { } } }); menu.add(sortInNode); JMenuItem sortOutNode = new JMenuItem("Sort out node"); sortOutNode.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { selectMode$ = SELECT_MODE_OUT; JItemPanel[] ipa = getItems(); ArrayList<JItemPanel> ipl = new ArrayList<JItemPanel>(Arrays.asList(ipa)); Collections.sort(ipl, new ItemPanelComparator()); panel.removeAll(); System.out.println("JBondsPanel:sort out node:ipl=" + ipl.size()); if (ipa != null) for (JItemPanel ip : ipl) { panel.add(ip); } revalidate(); repaint(); Entigrator entigrator = console.getEntigrator(entihome$); Sack entity = entigrator.getEntityAtKey(entityKey$); if (!entity.existsElement("parameter")) entity.createElement("parameter"); entity.putElementItem("parameter", new Core(null, SELECT_MODE, selectMode$)); entigrator.save(entity); } catch (Exception ee) { } } }); menu.add(sortOutNode); } @Override public void menuDeselected(MenuEvent e) { } @Override public void menuCanceled(MenuEvent e) { } }); return menu; }
From source file:lu.fisch.unimozer.Diagram.java
public void doAutoSave() { //if (saveTimer.isRunning()) saveTimer.stop(); if (hasChangedAutoSave == true) { // has the project allready been saved once? //if(directoryName==null) //{// w ww . j a v a2s . c o m // no, so ask to save it right now //custom title, warning icon Object[] options = { "Yes", "No" }; int n = JOptionPane.showOptionDialog(frame, "You didn't save your project yet!\n" + "Do you want to save it right now?", "Auto save", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (n == 0) { this.saveUnimozer(); hasChangedAutoSave = false; } //} /* else { // yes, so go ahead an create a backup createBackup(); hasChangedAutoSave=false; } saveTimer.start(); */ } else if (hasChanged) { Object[] options = { "Yes", "No" }; int n = JOptionPane.showOptionDialog(frame, "You didn't save your project for at least 10 minutes!\n" + "Do you want to save it right now?", "Auto save", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (n == 0) { this.saveUnimozer(); } } }
From source file:com.opendoorlogistics.studio.scripts.editor.ScriptEditor.java
public void disposeWithSavePrompt() { String currentXML = getXML(); if (currentXML.equals(lastOutputXML) == false) { if (JOptionPane.showConfirmDialog(ScriptEditor.this, "Script has been modified but not saved, changes will be lost. Really close?", "Really Closing?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { ScriptEditor.this.dispose(); }/*from w ww . j a va 2s .co m*/ } else { ScriptEditor.this.dispose(); } }