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:com.jvms.i18neditor.Editor.java
public void showFindTranslationDialog() { String key = (String) JOptionPane.showInputDialog(this, MessageBundle.get("dialogs.translation.find.text"), MessageBundle.get("dialogs.translation.find.title"), JOptionPane.QUESTION_MESSAGE); if (key != null) { TranslationTreeNode node = translationTree.findNodeByKey(key.trim()); if (node == null) { showWarning(MessageBundle.get("dialogs.translation.find.title"), MessageBundle.get("dialogs.translation.find.error")); } else {// w w w .ja va 2s . c om translationTree.setSelectedNode(node); } } }
From source file:gdt.jgui.base.JPropertyPanel.java
public void deleteProperty(JMainConsole console, String locator$) { try {// ww w.j a v a 2 s . co m Properties locator = Locator.toProperties(locator$); String entihome$ = locator.getProperty(Entigrator.ENTIHOME); Entigrator entigrator = console.getEntigrator(entihome$); String propertyName$ = locator.getProperty(JDesignPanel.PROPERTY_NAME); int response = JOptionPane.showConfirmDialog(console.getContentPanel(), "Delete property ?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) { entigrator.prp_deletePropertyName(propertyName$); JDesignPanel dp = new JDesignPanel(); String dpLocator$ = dp.getLocator(); dpLocator$ = Locator.append(dpLocator$, Entigrator.ENTIHOME, entihome$); JConsoleHandler.execute(console, dpLocator$); } } catch (Exception e) { LOGGER.severe(e.toString()); } }
From source file:edu.ku.brc.specify.tasks.AttachmentsTask.java
/** * /*from w w w . j a v a 2 s . c o m*/ */ private void exportAttachment(final CommandAction cmdAction) { exportFile = null; Object data = cmdAction.getData(); if (data instanceof ImageDataItem) { ImageDataItem idi = (ImageDataItem) data; System.out.println(idi.getImgName()); String origFilePath = BasicSQLUtils.querySingleObj( "SELECT OrigFilename FROM attachment WHERE AttachmentID = " + idi.getAttachmentId()); if (StringUtils.isNotEmpty(origFilePath)) { origFilePath = FilenameUtils.getName(origFilePath); } else { origFilePath = idi.getTitle(); } String usrHome = System.getProperty("user.home"); JFileChooser dlg = new JFileChooser(usrHome); dlg.setSelectedFile(new File(origFilePath)); int rv = dlg.showSaveDialog((Frame) UIRegistry.getTopWindow()); if (rv == JFileChooser.APPROVE_OPTION) { File file = dlg.getSelectedFile(); if (file != null) { String fullPath = file.getAbsolutePath(); String oldExt = FilenameUtils.getExtension(origFilePath); String newExt = FilenameUtils.getExtension(fullPath); if (StringUtils.isEmpty(newExt) && StringUtils.isNotEmpty(oldExt)) { fullPath += "." + oldExt; exportFile = new File(fullPath); } else { exportFile = file; } boolean isOK = true; if (exportFile.exists()) { isOK = UIRegistry.displayConfirmLocalized("ATTCH.FILE_EXISTS", "ATTCH.REPLACE_MSG", "ATTCH.REPLACE", "CANCEL", JOptionPane.QUESTION_MESSAGE); } if (isOK) { ImageLoader loader = new ImageLoader(idi.getImgName(), idi.getMimeType(), true, -1, this); ImageLoaderExector.getInstance().loadImage(loader); } } System.out.println(file.toPath()); } } }
From source file:org.fhaes.jsea.JSEAFrame.java
/** * Initialize the menu/toolbar actions./*from w ww.j a v a 2 s .c o m*/ */ private void initActions() { final JFrame glue = this; actionFileExit = new FHAESAction("Close", "close.png") { //$NON-NLS-1$ private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { dispose(); } }; actionChartProperties = new FHAESAction("Chart properties", "properties.png") { //$NON-NLS-1$ private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { ChartEditor editor = ChartEditorManager .getChartEditor(jsea.getChartList().get(segmentComboBox.getSelectedIndex()).getChart()); int result = JOptionPane.showConfirmDialog(glue, editor, "Properties", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (result == JOptionPane.OK_OPTION) { editor.updateChart(jsea.getChartList().get(segmentComboBox.getSelectedIndex()).getChart()); } } }; actionReset = new FHAESAction("Reset", "filenew.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { Object[] options = { "Yes", "No", "Cancel" }; int n = JOptionPane.showOptionDialog(glue, "Are you sure you want to start a new analysis?", "Confirm", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[2]); if (n == JOptionPane.YES_OPTION) { setToDefault(); } } }; actionRun = new FHAESAction("Run analysis", "run.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { runAnalysis(); } }; actionSaveAll = new FHAESAction("Save all results", "save_all.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { if (jsea == null) return; File file; JFileChooser fc; // Open file chooser in last folder if possible if (App.prefs.getPref(PrefKey.PREF_LAST_EXPORT_FOLDER, null) != null) { fc = new JFileChooser(App.prefs.getPref(PrefKey.PREF_LAST_EXPORT_FOLDER, null)); } else { fc = new JFileChooser(); } fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // Show dialog and get specified file int returnVal = fc.showSaveDialog(glue); if (returnVal == JFileChooser.APPROVE_OPTION) { file = fc.getSelectedFile(); App.prefs.setPref(PrefKey.PREF_LAST_EXPORT_FOLDER, file.getAbsolutePath()); } else { return; } File f; try { f = new File(file.getAbsolutePath() + File.separator + "report.txt"); saveReportTXT(f); f = new File(file.getAbsolutePath() + File.separator + "report.pdf"); saveReportPDF(f); f = new File(file.getAbsolutePath() + File.separator + "chart.png"); saveChartPNG(f); f = new File(file.getAbsolutePath() + File.separator + "chart.pdf"); saveChartPDF(f); f = new File(file.getAbsolutePath() + File.separator + "data.xls"); saveDataXLS(f); f = new File(file.getAbsolutePath()); saveDataCSV(f); } catch (IOException e) { e.printStackTrace(); } } }; actionSaveData = new FHAESAction("Save data tables", "table.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { if (jsea == null) return; File file; JFileChooser fc; // Open file chooser in last folder if possible if (App.prefs.getPref(PrefKey.PREF_LAST_EXPORT_FOLDER, null) != null) { fc = new JFileChooser(App.prefs.getPref(PrefKey.PREF_LAST_EXPORT_FOLDER, null)); } else { fc = new JFileChooser(); } fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // Show dialog and get specified file int returnVal = fc.showSaveDialog(glue); if (returnVal == JFileChooser.APPROVE_OPTION) { file = fc.getSelectedFile(); App.prefs.setPref(PrefKey.PREF_LAST_EXPORT_FOLDER, file.getAbsolutePath()); } else { return; } try { saveDataCSV(file); } catch (IOException e) { e.printStackTrace(); } } }; actionSaveReport = new FHAESAction("Save report", "report.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { if (jsea == null) return; File file; JFileChooser fc; // Open file chooser in last folder if possible if (App.prefs.getPref(PrefKey.PREF_LAST_EXPORT_FOLDER, null) != null) { fc = new JFileChooser(App.prefs.getPref(PrefKey.PREF_LAST_EXPORT_FOLDER, null)); } else { fc = new JFileChooser(); } // Set file filters fc.setAcceptAllFileFilterUsed(false); TXTFileFilter txtfilter = new TXTFileFilter(); PDFFilter pdffilter = new PDFFilter(); fc.addChoosableFileFilter(txtfilter); fc.addChoosableFileFilter(pdffilter); fc.setFileFilter(txtfilter); FileFilter chosenFilter; // Show dialog and get specified file int returnVal = fc.showSaveDialog(glue); if (returnVal == JFileChooser.APPROVE_OPTION) { file = fc.getSelectedFile(); chosenFilter = fc.getFileFilter(); App.prefs.setPref(PrefKey.PREF_LAST_EXPORT_FOLDER, file.getAbsolutePath()); } else { return; } // Handle file type and extensions nicely if (FilenameUtils.getExtension(file.getAbsolutePath()).equals("")) { if (chosenFilter.equals(txtfilter)) { file = new File(file.getAbsoluteFile() + ".txt"); } else if (chosenFilter.equals(pdffilter)) { file = new File(file.getAbsoluteFile() + ".pdf"); } } else if (FilenameUtils.getExtension(file.getAbsolutePath()).toLowerCase().equals("txt") && chosenFilter.equals("pdf")) { chosenFilter = txtfilter; } else if (FilenameUtils.getExtension(file.getAbsolutePath()).toLowerCase().equals("pdf") && chosenFilter.equals("txt")) { chosenFilter = pdffilter; } // If file already exists confirm overwrite if (file.exists()) { // Check we have write access to this file if (!file.canWrite()) { JOptionPane.showMessageDialog(glue, "You do not have write permission to this file", "Error", JOptionPane.ERROR_MESSAGE); return; } int n = JOptionPane.showConfirmDialog(glue, "File: " + file.getName() + " already exists. " + "Would you like to overwrite it?", "Overwrite file?", JOptionPane.YES_NO_OPTION); if (n != JOptionPane.YES_OPTION) { return; } } // Do save try { if (chosenFilter.equals(txtfilter)) { saveReportTXT(file); } else if (chosenFilter.equals(pdffilter)) { saveReportPDF(file); } else { log.error("No export file format chosen. Shouldn't be able to get here!"); } } catch (IOException e) { JOptionPane.showMessageDialog(glue, "Unable to save report. Check log file.", "Warning", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } } }; actionSaveChart = new FHAESAction("Save chart", "barchart.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { if (jsea == null) return; File file; JFileChooser fc; // Open file chooser in last folder if possible if (App.prefs.getPref(PrefKey.PREF_LAST_EXPORT_FOLDER, null) != null) { fc = new JFileChooser(App.prefs.getPref(PrefKey.PREF_LAST_EXPORT_FOLDER, null)); } else { fc = new JFileChooser(); } // Set file filters fc.setAcceptAllFileFilterUsed(false); PNGFilter pngfilter = new PNGFilter(); PDFFilter pdffilter = new PDFFilter(); fc.addChoosableFileFilter(pngfilter); fc.addChoosableFileFilter(pdffilter); fc.setFileFilter(pngfilter); FileFilter chosenFilter; // Show dialog and get specified file int returnVal = fc.showSaveDialog(glue); if (returnVal == JFileChooser.APPROVE_OPTION) { file = fc.getSelectedFile(); chosenFilter = fc.getFileFilter(); App.prefs.setPref(PrefKey.PREF_LAST_EXPORT_FOLDER, file.getAbsolutePath()); } else { return; } // Handle file type and extensions nicely if (FilenameUtils.getExtension(file.getAbsolutePath()).equals("")) { if (chosenFilter.equals(pngfilter)) { file = new File(file.getAbsoluteFile() + ".png"); } else if (chosenFilter.equals(pdffilter)) { file = new File(file.getAbsoluteFile() + ".pdf"); } } else if (FilenameUtils.getExtension(file.getAbsolutePath()).toLowerCase().equals("png") && chosenFilter.equals("pdf")) { chosenFilter = pngfilter; } else if (FilenameUtils.getExtension(file.getAbsolutePath()).toLowerCase().equals("pdf") && chosenFilter.equals("png")) { chosenFilter = pdffilter; } // If file already exists confirm overwrite if (file.exists()) { // Check we have write access to this file if (!file.canWrite()) { JOptionPane.showMessageDialog(glue, "You do not have write permission to this file", "Error", JOptionPane.ERROR_MESSAGE); return; } int n = JOptionPane.showConfirmDialog(glue, "File: " + file.getName() + " already exists. " + "Would you like to overwrite it?", "Overwrite file?", JOptionPane.YES_NO_OPTION); if (n != JOptionPane.YES_OPTION) { return; } } // Do save try { if (chosenFilter.equals(pngfilter)) { saveChartPNG(file); } else if (chosenFilter.equals(pdffilter)) { saveChartPDF(file); } else { log.error("No export file format chosen. Shouldn't be able to get here!"); } } catch (IOException e) { JOptionPane.showMessageDialog(glue, "Unable to save chart. Check log file.", "Warning", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } } }; actionCopy = new FHAESAction("Copy", "edit_copy.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { copyCurrentSelectionToClipboard(); } }; actionLagMap = new FHAESAction("LagMap", "lagmap22.png") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { launchLagMap(); } }; }
From source file:de.juwimm.cms.util.Communication.java
public boolean exitPerformed(ExitEvent e) { log.info("Exit-event started"); int result = JOptionPane.showConfirmDialog(UIConstants.getMainFrame(), rb.getString("dialog.exit.text"), rb.getString("dialog.exit"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (result == JOptionPane.YES_OPTION) { if (!checkOutPages.isEmpty()) { ArrayList<ContentValue> pageList = new ArrayList<ContentValue>(); Iterator it = checkOutPages.iterator(); while (it.hasNext()) { try { ContentValue current = getClientService().getContent(((Integer) it.next())); pageList.add(current); } catch (Exception ex) { String msg = Messages.getString("exception.checkingInAllRemainingPages", Integer.toString(checkOutPages.size())); log.info(msg);//from ww w . j a v a2 s. c o m JOptionPane.showMessageDialog(UIConstants.getMainFrame(), msg, rb.getString("dialog.title"), JOptionPane.INFORMATION_MESSAGE); UIConstants.getMainFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); while (it.hasNext()) { Integer contentId = (Integer) it.next(); try { msg = Messages.getString("exception.checkingInAllRemainingPagesStatusbar", contentId.toString()); UIConstants.setActionStatus(msg); getClientService().checkIn4ContentId(contentId); } catch (Exception exe) { log.error("Exit event error", exe); } } checkOutPages = new ArrayList<Integer>(); UIConstants.getMainFrame().setCursor(Cursor.getDefaultCursor()); try { if (log.isDebugEnabled()) { log.debug("Calling logout on server"); } getClientService().logout(); } catch (Exception exe) { } log.info("Goodbye!"); loggedIn = false; return true; } } PanCheckInPages pan = new PanCheckInPages(pageList); if (rb == null) rb = Constants.rb; DlgModal dlg = new DlgModal(pan, 300, 500, rb.getString("DlgModal.checkin")); dlg.addOkListener(new OkListener(pan, dlg)); dlg.setVisible(true); } try { if (log.isDebugEnabled()) { log.debug("Calling logout on server"); } getClientService().logout(); } catch (Exception exe) { } log.info("Goodbye!"); loggedIn = false; return true; } return false; }
From source file:com._17od.upm.gui.DatabaseActions.java
/** * Prompt the user to enter a password/*from w w w .j ava2 s . c o m*/ * @return The password entered by the user or null of this hit escape/cancel */ private char[] askUserForPassword(String message) { char[] password = null; final JPasswordField masterPassword = new JPasswordField(""); JOptionPane pane = new JOptionPane(new Object[] { message, masterPassword }, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION); JDialog dialog = pane.createDialog(mainWindow, Translator.translate("masterPassword")); dialog.addWindowFocusListener(new WindowAdapter() { public void windowGainedFocus(WindowEvent e) { masterPassword.requestFocusInWindow(); } }); dialog.show(); if (pane.getValue() != null && pane.getValue().equals(new Integer(JOptionPane.OK_OPTION))) { password = masterPassword.getPassword(); } return password; }
From source file:com.floreantpos.ui.views.SwitchboardView.java
protected void doAssignDriver() { try {/* w w w.j a v a 2s.c o m*/ Ticket ticket = getFirstSelectedTicket(); if (ticket == null) { return; } if (!ticket.getOrderType().isDelivery()) { POSMessageDialog.showError(this, Messages.getString("SwitchboardView.8")); //$NON-NLS-1$ return; } User assignedDriver = ticket.getAssignedDriver(); if (assignedDriver != null) { int option = JOptionPane.showOptionDialog(Application.getPosWindow(), Messages.getString("SwitchboardView.9"), POSConstants.CONFIRM, //$NON-NLS-1$ JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); if (option != JOptionPane.YES_OPTION) { return; } } orderServiceExtension.assignDriver(ticket.getId()); } catch (Exception e) { PosLog.error(getClass(), e); POSMessageDialog.showError(this, e.getMessage()); LogFactory.getLog(SwitchboardView.class).error(e); } }
From source file:com.ejie.uda.jsonI18nEditor.Editor.java
public void showRenameTranslationDialog(String key) { String newKey = ""; while (newKey != null && newKey.isEmpty()) { newKey = (String) JOptionPane.showInputDialog(this, MessageBundle.get("dialogs.translation.rename.text"), MessageBundle.get("dialogs.translation.rename.title"), JOptionPane.QUESTION_MESSAGE, null, null, key);/*from ww w .j a va2 s . co m*/ if (newKey != null) { newKey = newKey.trim(); if (!TranslationKeys.isValid(newKey)) { showError(MessageBundle.get("dialogs.translation.rename.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) { renameTranslationKey(key, newKey); } } else { renameTranslationKey(key, newKey); } } } } }
From source file:com.jwmsolutions.timeCheck.gui.TodoForm.java
private void jchkCompletedActionPerformed(ActionEvent evt) { String todoName = (String) jcbTodos.getSelectedItem(); boolean isCompletedTodo = StringUtils.containsIgnoreCase(todoName, CoreObject.getConfig().getString(Constants.CONFIG_COMPLETED_ITEM_TAG)); if (jchkCompleted.isSelected() && !isCompletedTodo) { String message = "This to-do item will be marked as completed. Are you sure to continue?"; String title = "Complete To-Do Item"; int optionType = JOptionPane.YES_NO_OPTION; int messageType = JOptionPane.QUESTION_MESSAGE; int selectedOption = JOptionPane.showOptionDialog(this, message, title, optionType, messageType, null, null, null);//from w w w.ja va 2 s. c o m if (selectedOption == JOptionPane.YES_OPTION) { String todoDescription = (String) jcbTodos.getSelectedItem(); BasecampTodoItem todoItem = CoreObject.getTodoMap().get(todoDescription); Integer todoItemId = todoItem.getId(); String statusCode = BasecampBusiness.completeTodoItem(todoItemId.toString()); if (statusCode.trim().equals("200") || statusCode.trim().equals("201")) { jtfHours.setText("0"); jDateChooser_IL.setDate(new Date()); jchkCompleted.setSelected(false); jtfDescription.setText(""); CoreObject.reloadTodoMap(); lblMessages.setText("ToDo has been completed!"); } else { lblMessages.setText("Failed! Status: " + statusCode); } } else { jchkCompleted.setSelected(false); } } else { if (isCompletedTodo) { String message = "This to-do item will be marked as uncompleted. Are you sure to activate the item?"; String title = "Activate To-Do Item"; int optionType = JOptionPane.YES_NO_OPTION; int messageType = JOptionPane.QUESTION_MESSAGE; int selectedOption = JOptionPane.showOptionDialog(this, message, title, optionType, messageType, null, null, null); if (selectedOption == JOptionPane.YES_OPTION) { String todoDescription = (String) jcbTodos.getSelectedItem(); BasecampTodoItem todoItem = CoreObject.getTodoMap().get(todoDescription); Integer todoItemId = todoItem.getId(); String statusCode = BasecampBusiness.uncompleteTodoItem(todoItemId.toString()); if (statusCode.trim().equals("200") || statusCode.trim().equals("201")) { jtfHours.setText("0"); jDateChooser_IL.setDate(new Date()); jchkCompleted.setSelected(false); jtfDescription.setText(""); CoreObject.reloadTodoMap(); lblMessages.setText("ToDo is now active!"); } else { lblMessages.setText("Failed! Status: " + statusCode); } } else { jchkCompleted.setSelected(true); } } } }
From source file:de.huxhorn.lilith.swing.preferences.PreferencesDialog.java
public void reinitializeDetailsViewFiles() { String dialogTitle = "Reinitialize details view files?"; String message = "This resets all details view related files, all manual changes will be lost!\nReinitialize details view 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 w w w. j a v a2s.co m*/ } applicationPreferences.initDetailsViewRoot(true); }