List of usage examples for javax.swing JOptionPane YES_OPTION
int YES_OPTION
To view the source code for javax.swing JOptionPane YES_OPTION.
Click Source Link
From source file:ar.edu.uns.cs.vyglab.arq.rockar.gui.JFrameControlPanel.java
private void checkToSave() { if (this.jTableMineralsModel.getRowCount() > 0) { int response = JOptionPane.showConfirmDialog(this, DataCenter.langResource.getString("save_mineral_table")); if (response == JOptionPane.YES_OPTION) { this.saveTable(); }//from w w w . j a va 2s. c o m } }
From source file:com.mirth.connect.connectors.file.FileWriter.java
private void schemeComboBoxActionPerformed(ActionEvent evt) { String text = (String) schemeComboBox.getSelectedItem(); if (!text.equals(selectedScheme)) { if (StringUtils.isNotEmpty(selectedScheme) && !isAdvancedDefault()) { if (JOptionPane.showConfirmDialog(parent, "Are you sure you would like to change the scheme mode and lose all of the current properties?", "Select an Option", JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) { schemeComboBox.setSelectedItem(selectedScheme); return; }/*from w w w . j a va 2 s.co m*/ } // if File is selected if (text.equals(FileScheme.FILE.getDisplayName())) { onSchemeChange(false, true, true, FileScheme.FILE); } // else if FTP is selected else if (text.equals(FileScheme.FTP.getDisplayName())) { onSchemeChange(true, anonymousYesRadio.isSelected(), true, FileScheme.FTP); hostLabel.setText("ftp://"); } // else if SFTP is selected else if (text.equals(FileScheme.SFTP.getDisplayName())) { onSchemeChange(true, false, true, FileScheme.SFTP); hostLabel.setText("sftp://"); } // else if SMB is selected else if (text.equals(FileScheme.SMB.getDisplayName())) { onSchemeChange(true, false, true, FileScheme.SMB); hostLabel.setText("smb://"); } // else if WEBDAV is selected else if (text.equals(FileScheme.WEBDAV.getDisplayName())) { onSchemeChange(true, anonymousYesRadio.isSelected(), false, FileScheme.WEBDAV); if (secureModeYesRadio.isSelected()) { hostLabel.setText("https://"); } else { hostLabel.setText("http://"); } } decorateConnectorType(); } selectedScheme = text; }
From source file:com.sshtools.sshterm.SshTerminalPanel.java
private boolean performVerifiedDisconnect(boolean force) { // Lets examine the profile to see if we need to close the connection SshToolsConnectionProfile profile = getCurrentConnectionProfile(); if (profile.disconnectOnSessionClose()) { // Yes we should, lets ask the user about any forwarding channels if (ssh.getForwardingClient().hasActiveConfigurations()) { return (JOptionPane.showConfirmDialog(SshTerminalPanel.this, "There are currently active forwarding channels!\n\n" + "The profile is configured to disconnect when the session is closed. Closing\n" + "the connection will terminate these forwarding channels with unexpected results.\n\n" + "Do you want to disconnect now?", "Auto disconnect", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION); } else {/*ww w. j av a 2 s . c o m*/ return true; } } return force; }
From source file:com.proyecto.vista.MantenimientoBien.java
private void btneliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btneliminarActionPerformed // TODO add your handling code here: accion = Controlador.ELIMINAR;/* w ww .j ava 2 s .c o m*/ if (tblbienes.getSelectedRow() != -1) { Integer codigo = tblbienes.getSelectedRow(); Bien bien = bienControlador.buscarPorId(lista.get(codigo).getId()); if (bien != null) { if (JOptionPane.showConfirmDialog(null, "Desea Eliminar la Bien?", "Mensaje del Sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { int[] filas = tblbienes.getSelectedRows(); for (int i = 0; i < filas.length; i++) { Bien bien2 = lista.get(filas[0]); lista.remove(bien2); bienControlador.setSeleccionado(bien2); bienControlador.accion(accion); } if (bienControlador.accion(accion) == 3) { JOptionPane.showMessageDialog(null, "Bien eliminada correctamente", "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(null, "Bien no eliminada", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } else { JOptionPane.showMessageDialog(null, "Bien no eliminada", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } } else { JOptionPane.showMessageDialog(null, "Debe seleccionar un Bien", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } }
From source file:com.clough.android.adbv.view.MainFrame.java
private void showTreeNodePopup(int x, int y, boolean isDatabasePopup) { JPopupMenu treeNodePopup = new JPopupMenu(); if (isDatabasePopup) { JMenuItem newTableMenuItem = new JMenuItem("New table"); newTableMenuItem.addActionListener(new ActionListener() { @Override/*w ww. ja va2 s . co m*/ public void actionPerformed(ActionEvent e) { System.out.println("new table"); new CreateTableDialog(MainFrame.this, true).setVisible(true); if (tableQueryList != null && tableQueryList.size() > 0) { for (String query : tableQueryList.values()) { inputQuery = query; runQuery(); } refreshDatabase(); tableQueryList = null; } } }); treeNodePopup.add(newTableMenuItem); } else { JMenuItem viewAllMenuItem = new JMenuItem("View table"); viewAllMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.out.println("view all"); inputQuery = "select * from `" + selectedTreeNodeValue + "`"; queryingTextArea.setText(inputQuery); runQuery(); } }); treeNodePopup.add(viewAllMenuItem); JMenuItem dropTableMenuItem = new JMenuItem("Drop table"); dropTableMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.out.println("drop table"); if (JOptionPane.showConfirmDialog(null, "All the data in table " + selectedTreeNodeValue + " will be lost!\nClick OK to delete the table", "Sqlite table dropping", JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) { inputQuery = "drop table `" + selectedTreeNodeValue + "`"; queryingTextArea.setText(inputQuery); runQuery(); refreshDatabase(); } } }); treeNodePopup.add(dropTableMenuItem); JMenuItem updateTableMenuItem = new JMenuItem("Update table"); updateTableMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.out.println("update table"); final Object[] columnsOfTable = getColumnsOfTable(selectedTreeNodeValue); new SwingWorker<Void, Void>() { String result; @Override protected Void doInBackground() throws Exception { try { Thread.sleep(100); } catch (InterruptedException ex) { } result = ioManager.executeQuery("select * from `" + selectedTreeNodeValue + "`"); return null; } @Override protected void done() { closeProgressDialog(); new UpdateTableDialog(MainFrame.this, true, result, selectedTreeNodeValue, columnsOfTable).setVisible(true); } }.execute(); showProgressDialog(true, 0, "Recieving data from table " + selectedTreeNodeValue); if ((rowsToInsert != null && rowsToInsert.size() > 0) || (rowsToUpdate != null && rowsToUpdate.size() > 0) || (rowsToDelete != null && rowsToDelete.size() > 0)) { new SwingWorker<Void, Void>() { @Override protected Void doInBackground() { try { Thread.sleep(100); } catch (InterruptedException ex) { } String result = ""; try { for (Row row : rowsToInsert) { String insertQuery = createTableInsertQuery(selectedTreeNodeValue, row); System.out.println("insertQuery : " + insertQuery); result = ioManager.executeQuery(insertQuery); if (result.equals("[]")) { waitingDialog.incrementProgressBar(); } else { throw new Exception(); } } for (Row row : rowsToUpdate) { String updateQuery = createTableUpdateQuery(selectedTreeNodeValue, row); System.out.println("updateQuery : " + updateQuery); result = ioManager.executeQuery(updateQuery); if (result.equals("[]")) { waitingDialog.incrementProgressBar(); } else { throw new Exception(); } } for (Row row : rowsToDelete) { String deleteQuery = createTableDeleteQuery(selectedTreeNodeValue, row); System.out.println("deleteQuery : " + deleteQuery); result = ioManager.executeQuery(deleteQuery); if (result.equals("[]")) { waitingDialog.incrementProgressBar(); } else { throw new Exception(); } } } catch (Exception ex) { JOptionPane.showMessageDialog(null, result, "Result error", JOptionPane.ERROR_MESSAGE); } return null; } @Override protected void done() { closeProgressDialog(); refreshDatabase(); rowsToInsert = null; rowsToUpdate = null; rowsToDelete = null; } }.execute(); showProgressDialog(false, rowsToInsert.size() + rowsToUpdate.size() + rowsToDelete.size(), "Applying changes to the dialog " + selectedTreeNodeValue); } } }); treeNodePopup.add(updateTableMenuItem); JMenuItem copyCreateStatementMenuItem = new JMenuItem("Copy create statement"); copyCreateStatementMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.out.println("copy create statement"); for (int i = 0; i < tables.length; i++) { if (tables[i].equals(selectedTreeNodeValue)) { StringSelection selection = new StringSelection(queries[i]); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, selection); JOptionPane.showMessageDialog(null, "Copied create statement of the table `" + selectedTreeNodeValue + "` to the clipboard", "Copy create statement", JOptionPane.INFORMATION_MESSAGE); break; } } } }); treeNodePopup.add(copyCreateStatementMenuItem); JMenuItem copyColumnNamesMenuItem = new JMenuItem("Copy column names"); copyColumnNamesMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.out.println("copy column names"); for (int i = 0; i < tables.length; i++) { if (tables[i].equals(selectedTreeNodeValue)) { String columnNames = ""; for (String column : columns[i]) { columnNames = columnNames.concat(column + ","); } StringSelection selection = new StringSelection( columnNames.substring(0, columnNames.length() - 1)); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, selection); JOptionPane.showMessageDialog(null, "Copied create statement of the table `" + selectedTreeNodeValue + "` to the clipboard", "Copy create statement", JOptionPane.INFORMATION_MESSAGE); break; } } } }); treeNodePopup.add(copyColumnNamesMenuItem); } treeNodePopup.show(tableInfoTree, x, y); }
From source file:edu.harvard.i2b2.previousquery.QueryPreviousRunsPanel.java
public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equalsIgnoreCase("Rename ...")) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent(); QueryMasterData ndata = (QueryMasterData) node.getUserObject(); Object inputValue = JOptionPane.showInputDialog(this, "Rename this query to: ", "Rename Query Dialog", JOptionPane.PLAIN_MESSAGE, null, null, ndata.name().substring(0, ndata.name().lastIndexOf("[") - 1)); if (inputValue != null) { String newQueryName = (String) inputValue; String requestXml = ndata.writeRenameQueryXML(newQueryName); lastRequestMessage = requestXml; setCursor(new Cursor(Cursor.WAIT_CURSOR)); String response = QueryListNamesClient.sendQueryRequestREST(requestXml); if (response.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); }/*w ww . j a v a2 s .c om*/ }); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); return; } lastResponseMessage = response; if (response != null) { JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil(); try { JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response); ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue(); StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus(); String status = statusType.getType(); if (status.equalsIgnoreCase("DONE")) { ndata.name(newQueryName + " [" + ndata.userId() + "]"); node.setUserObject(ndata); //DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent(); jTree1.repaint(); } } catch (Exception ex) { ex.printStackTrace(); } } setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } } else if (e.getActionCommand().equalsIgnoreCase("Delete")) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent(); QueryMasterData ndata = (QueryMasterData) node.getUserObject(); Object selectedValue = JOptionPane.showConfirmDialog(this, "Delete Query \"" + ndata.name() + "\"?", "Delete Query Dialog", JOptionPane.YES_NO_OPTION); if (selectedValue.equals(JOptionPane.YES_OPTION)) { System.out.println("delete " + ndata.name()); String requestXml = ndata.writeDeleteQueryXML(); lastRequestMessage = requestXml; //System.out.println(requestXml); setCursor(new Cursor(Cursor.WAIT_CURSOR)); String response = QueryListNamesClient.sendQueryRequestREST(requestXml); if (response.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); return; } lastResponseMessage = response; if (response != null) { JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil(); try { JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response); ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue(); StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus(); String status = statusType.getType(); if (status.equalsIgnoreCase("DONE")) { treeModel.removeNodeFromParent(node); //jTree1.repaint(); } } catch (Exception ex) { ex.printStackTrace(); } } setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } } else if (e.getActionCommand().equalsIgnoreCase("Refresh All")) { String status = loadPreviousQueries(false); if (status.equalsIgnoreCase("")) { reset(200, false); } else if (status.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); } } }
From source file:edu.ku.brc.specify.tasks.subpane.security.SecurityAdminPane.java
/** * @param objWrapper//from ww w. j a va 2 s . co m * @param groupObjWrapper * @param selectedObjTitle */ /*private void showInfoPanel(final DataModelObjBaseWrapper objWrapperArg, final DataModelObjBaseWrapper userObjWrapperArg, final DataModelObjBaseWrapper groupObjWrapperArg, final DataModelObjBaseWrapper collectionWrapperArg, final String selectedObjTitle) { String className = objWrapperArg.getType(); CardLayout cardLayout = (CardLayout)(infoCards.getLayout()); // This displays the panel that says they have all permissions DataModelObjBaseWrapper wrpr = groupObjWrapperArg != null ? groupObjWrapperArg : objWrapperArg; if (wrpr != null) { Object dataObj = wrpr.getDataObj(); if (dataObj instanceof SpPrincipal && ((SpPrincipal)dataObj).getGroupSubClass().equals(AdminPrincipal.class.getName())) { cardLayout.show(infoCards, AdminPrincipal.class.getCanonicalName()); return; } } if (currentEditorPanel != null && currentEditorPanel.hasChanged()) { String[] optionLabels = new String[] {getResourceString("SaveChangesBtn"), getResourceString("DiscardChangesBtn"), getResourceString("CANCEL")}; int rv = JOptionPane.showOptionDialog(UIRegistry.getTopWindow(), UIRegistry.getLocalizedMessage("SaveChanges", currentTitle), getResourceString("SaveChangesTitle"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, optionLabels, optionLabels[0]); if (rv == JOptionPane.YES_OPTION) { doSave(true); } } currentTitle = selectedObjTitle; // show info panel that corresponds to the type of object selected AdminInfoSubPanelWrapper panelWrapper = infoSubPanels.get(className); currentEditorPanel = editorPanels.get(className); if (currentEditorPanel != null) { currentEditorPanel.setHasChanged(false); } // fill form with object data if (panelWrapper != null) { currentDisplayPanel = panelWrapper; if (currentDisplayPanel.setData(objWrapperArg, userObjWrapperArg, groupObjWrapperArg, collectionWrapperArg, nodesDivision) && currentEditorPanel != null) { currentEditorPanel.setHasChanged(true); } cardLayout.show(infoCards, className); } objWrapper = objWrapperArg; groupObjWrapper = groupObjWrapperArg; collectionObjWrapper = collectionWrapperArg; }*/ private void showInfoPanel(final DataModelObjBaseWrapper objWrapperArg, final DataModelObjBaseWrapper secondObjWrapperArg, final DataModelObjBaseWrapper collectionWrapperArg, final String selectedObjTitle) { String className = objWrapperArg.getType(); CardLayout cardLayout = (CardLayout) (infoCards.getLayout()); // This displays the panel that says they have all permissions DataModelObjBaseWrapper wrpr = secondObjWrapperArg != null ? secondObjWrapperArg : objWrapperArg; if (wrpr != null) { Object dataObj = wrpr.getDataObj(); if (dataObj instanceof SpPrincipal && ((SpPrincipal) dataObj).getGroupSubClass().equals(AdminPrincipal.class.getName())) { cardLayout.show(infoCards, AdminPrincipal.class.getCanonicalName()); return; } } if (currentEditorPanel != null && currentEditorPanel.hasChanged()) { String[] optionLabels = new String[] { getResourceString("SaveChangesBtn"), getResourceString("DiscardChangesBtn"), getResourceString("CANCEL") }; int rv = JOptionPane.showOptionDialog(UIRegistry.getTopWindow(), UIRegistry.getLocalizedMessage("SaveChanges", currentTitle), getResourceString("SaveChangesTitle"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, optionLabels, optionLabels[0]); if (rv == JOptionPane.YES_OPTION) { doSave(true); } } currentTitle = selectedObjTitle; // show info panel that corresponds to the type of object selected AdminInfoSubPanelWrapper panelWrapper = infoSubPanels.get(className); currentEditorPanel = editorPanels.get(className); if (currentEditorPanel != null) { currentEditorPanel.setHasChanged(false); } // fill form with object data if (panelWrapper != null) { currentDisplayPanel = panelWrapper; if (currentDisplayPanel.setData(objWrapperArg, secondObjWrapperArg, collectionWrapperArg, nodesDivision) && currentEditorPanel != null) { currentEditorPanel.setHasChanged(true); } cardLayout.show(infoCards, className); } objWrapper = objWrapperArg; secondObjWrapper = secondObjWrapperArg; collectionWrapper = collectionWrapperArg; }
From source file:AppSpringLayout.java
protected void saveFileChooser(String fileUrl) { fc.setDialogTitle("Specify name of the file to save"); File output = new File(fc.getSelectedFile().toString()); // check if file already exists, ask user if they wish to overwrite it if (output.exists()) { int response = JOptionPane.showConfirmDialog(null, // "Do you want to replace the existing file?", // "Confirm", JOptionPane.YES_NO_OPTION, // JOptionPane.QUESTION_MESSAGE); if (response != JOptionPane.YES_OPTION) { return; }/* w w w . j av a 2 s.c o m*/ } fc.setSelectedFile(output); try { URL fileNameAsUrl = new URL(fileUrl); originalImage = ImageIO.read(fileNameAsUrl); ImageIO.write(toBufferedImage(originalImage), "jpeg", output); System.out.println("image saved, in the folder: " + output.getAbsolutePath()); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:jeplus.gui.JPanel_EPlusProjectFiles.java
private void cmdEditTemplateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdEditTemplateActionPerformed // Test if the template file is present String fn = (String) cboTemplateFile.getSelectedItem(); String templfn = RelativeDirUtil.checkAbsolutePath(txtIdfDir.getText() + fn, Project.getBaseDir()); File ftmpl = new File(templfn); if (!ftmpl.exists()) { int n = JOptionPane.showConfirmDialog(MainGUI, "<html><p><center>The template file " + templfn + " does not exist." + "Do you want to select one?</center></p><p> Select 'NO' to create this file. </p>", "Template file not available", JOptionPane.YES_NO_OPTION); if (n == JOptionPane.YES_OPTION) { this.cmdSelectTemplateFileActionPerformed(null); templfn = txtIdfDir.getText() + (String) cboTemplateFile.getSelectedItem(); }//from w ww . j av a 2s . c om } else { if (ftmpl.length() > 2000000) { int n = JOptionPane.showConfirmDialog(MainGUI, "<html><p><center>jEPlus editor does not handle large IDF models well.<br />Open " + templfn + " may slow down your computer considerably.<br />" + "Do you want to continue?<br /> </center></p>", "Template file is too big", JOptionPane.YES_NO_OPTION); if (n == JOptionPane.NO_OPTION) { return; } } } int idx = MainGUI.getTpnEditors().indexOfTab(fn); if (idx >= 0) { MainGUI.getTpnEditors().setSelectedIndex(idx); } else { // EPlusTextPanel TemplFilePanel = new EPlusTextPanel( // MainGUI.getTpnEditors(), // fn, // EPlusTextPanel.EDITOR_MODE, // EPlusConfig.getFileFilter(EPlusConfig.EPINPUT), // templfn, // Project); EPlusEditorPanel TemplFilePanel = new EPlusEditorPanel(MainGUI.getTpnEditors(), fn, templfn, EPlusEditorPanel.FileType.IDF, Project); int ti = MainGUI.getTpnEditors().getTabCount(); TemplFilePanel.setTabId(ti); MainGUI.getTpnEditors().addTab(fn, TemplFilePanel); MainGUI.getTpnEditors().setSelectedIndex(ti); MainGUI.getTpnEditors().setTabComponentAt(ti, new ButtonTabComponent(MainGUI.getTpnEditors(), TemplFilePanel)); MainGUI.getTpnEditors().setToolTipTextAt(ti, templfn); } }
From source file:edu.ku.brc.specify.tools.l10nios.StrLocalizerAppForiOS.java
/** * @return true if no unsaved changes are present * else return results of prompt to save */// w w w .j a v a 2s . c o m protected boolean checkForChanges() { // if (termList != null) // { // int s = termList.getSelectedIndex(); // if (s != -1) // { // L10NItem entry = srcFile.getKey(s); // entry.setDstStr(textField.getText()); // } // if (srcFile.isEdited()) // { // int response = JOptionPane.showOptionDialog((Frame )getTopWindow(), // String.format(getResourceString("StrLocalizerApp.SaveChangesMsg"), destFile.getPath()), // getResourceString("StrLocalizerApp.SaveChangesTitle"), // JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, JOptionPane.YES_OPTION); // if (response == JOptionPane.CANCEL_OPTION) // { // return false; // } // if (response == JOptionPane.YES_OPTION) // { // doSave(); // return true; //what if it fails? // } // } // return true; // } boolean hasChanges = false; for (L10NFile f : srcFiles) { if (f.isChanged()) { hasChanges = true; break; } } if (hasChanges) { int response = JOptionPane.showOptionDialog((Frame) getTopWindow(), "Changes have not been saved.\n\nDo you wish to save them?", getResourceString("StrLocalizerApp.SaveChangesTitle"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, JOptionPane.YES_OPTION); if (response == JOptionPane.CANCEL_OPTION) { return false; } if (response == JOptionPane.YES_OPTION) { doSave(); return true; //what if it fails? } } return true; }