List of usage examples for javax.swing JOptionPane CANCEL_OPTION
int CANCEL_OPTION
To view the source code for javax.swing JOptionPane CANCEL_OPTION.
Click Source Link
From source file:ca.uviccscu.lp.server.main.MainFrame.java
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed l.info("Remove game action activated"); //JOptionPane conf = new JOptionPane(); if (jTable1.getSelectedRow() >= 0) { int result = JOptionPane.showConfirmDialog(rootPane, "Are you sure you want to delete?", "Confirmation", 2, 3);/*from w w w. j a v a 2 s . c o m*/ //JDialog dialog = conf.createDialog(jPanel1, "Are you sure u want to delete?"); //dialog.show(); //Object selectedValue = conf.getValue(); l.trace("Game delete dialog code: " + result); if (result == JOptionPane.CANCEL_OPTION || result == JOptionPane.CLOSED_OPTION) { l.trace("Game delete cancelled"); } else if (result == JOptionPane.OK_OPTION) { DefaultTableModel mdl = (DefaultTableModel) jTable1.getModel(); String name = (String) mdl.getValueAt(jTable1.getSelectedRow(), 0); if (name != null) { l.trace("Removing game: " + name); GamelistStorage.removeGame(name); SettingsManager.getStorage().removeGame(name); mdl.removeRow(jTable1.getSelectedRow()); l.debug("Game removed: " + name); } else { mdl.removeRow(jTable1.getSelectedRow()); l.trace("Empty row - just erasing in table"); } } } MainFrame.updateGameInterfaceFromStorage(); }
From source file:com.mgmtp.perfload.loadprofiles.ui.AppFrame.java
private boolean checkLoadProfileEntityDirty() { if (activeLoadProfileEntityPanel != null && activeLoadProfileEntityPanel.isDirty()) { switch (JOptionPane.showConfirmDialog(AppFrame.this, "Save active curve assignment?")) { case JOptionPane.YES_OPTION: saveLoadProfileEntity(false); return true; case JOptionPane.NO_OPTION: cancelEditingCurveAssignment(); return true; case JOptionPane.CANCEL_OPTION: default://from w w w .ja va 2 s .c om // don't allow to change tree selection tree.setSelectionPath(activeLeafPath); return false; } } return true; }
From source file:fur.shadowdrake.minecraft.InstallPanel.java
private void forceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_forceActionPerformed if (force.isSelected()) { if (JOptionPane.showConfirmDialog(this, "Forcing a reinstall will clean up the directory resulting in a loss of all settings!", "Reinstall", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.CANCEL_OPTION) { force.setSelected(false);//from ww w. j a v a2 s . c o m return; } } boolean isInstalled = false; for (Pack p : packList) { if (p.name.equals(modpackChooser.getSelectedItem())) { isInstalled = true; } } dirBox.setEnabled(!isInstalled || force.isSelected()); browse.setEnabled(!isInstalled || force.isSelected()); }
From source file:com.mgmtp.perfload.loadprofiles.ui.AppFrame.java
private boolean checkLoadProfilePropertiesDirty() { if (dirty) {// www. jav a 2 s .c o m switch (JOptionPane.showConfirmDialog(AppFrame.this, "Save load profile changes?")) { case JOptionPane.YES_OPTION: saveLoadProfileConfiguration(false); return true; case JOptionPane.NO_OPTION: return true; case JOptionPane.CANCEL_OPTION: default: return false; } } return true; }
From source file:edu.ku.brc.af.ui.forms.FormViewObj.java
public boolean isDataCompleteAndValid(final boolean throwAwayOnDiscard) { //log.debug((formValidator != null) +" "+ formValidator.hasChanged() +" "+mvParent.isTopLevel() +" "+ mvParent.hasChanged()); // Figure out if it is New and whether it has changed or is incomplete boolean isNewAndComplete = true; if (mvParent != null) { Object topParentData = mvParent.getTopLevel().getData(); if (topParentData != null && topParentData instanceof FormDataObjIFace) { if (((FormDataObjIFace) topParentData).getId() == null) { if (formValidator != null && dataObj != null) { isNewAndComplete = formValidator.isFormValid(); }/* ww w .j a v a 2 s . c o m*/ } } } //log.debug("Form Val: "+(formValidator != null && formValidator.hasChanged())); //log.debug("mvParent Val: "+(mvParent != null && mvParent.isTopLevel() && mvParent.hasChanged())); //if ((formValidator != null && formValidator.hasChanged()) || // (mvParent != null && mvParent.isTopLevel() && mvParent.hasChanged())) if (!doingDiscard && mvParent != null && mvParent.isTopLevel() && mvParent.hasChanged()) { try { doingDiscard = true; String title = null; if (dataObj != null) { if (tableInfo == null) { tableInfo = DBTableIdMgr.getInstance() .getByShortClassName(dataObj.getClass().getSimpleName()); } title = tableInfo != null ? tableInfo.getTitle() : null; if (StringUtils.isEmpty(title)) { title = UIHelper.makeNamePretty(dataObj.getClass().getSimpleName()); } } if (StringUtils.isEmpty(title)) { title = "data"; // I18N, not really sure what to put here. } // For the DISCARD // Since JOptionPane doesn't have a YES_CANCEL_OPTION // I have to use YES_NO_OPTION and since this is a Discard question // the rv has completely different meanings: // YES -> Means don't save (Discard) and close dialog (return true) // NO -> Means do nothing so return false String[] optionLabels; int dlgOptions; int defaultRV; if (!isNewAndComplete || (formValidator != null && !formValidator.isFormValid())) { dlgOptions = JOptionPane.YES_NO_OPTION; optionLabels = new String[] { getResourceString("DiscardChangesBtn"), getResourceString("CANCEL") }; defaultRV = JOptionPane.NO_OPTION; } else { dlgOptions = JOptionPane.YES_NO_CANCEL_OPTION; optionLabels = new String[] { getResourceString("SaveChangesBtn"), getResourceString("DiscardChangesBtn"), getResourceString("CANCEL") }; defaultRV = JOptionPane.CANCEL_OPTION; } int rv = JOptionPane.showOptionDialog(UIRegistry.getTopWindow(), isNewAndComplete ? UIRegistry.getLocalizedMessage("DiscardChanges", title) : UIRegistry.getLocalizedMessage("SaveChanges", title), isNewAndComplete ? getResourceString("DiscardChangesTitle") : getResourceString("SaveChangesTitle"), dlgOptions, JOptionPane.QUESTION_MESSAGE, null, optionLabels, optionLabels[0]); if (rv == JOptionPane.CLOSED_OPTION) { rv = defaultRV; } if (dlgOptions == JOptionPane.YES_NO_OPTION) { if (rv == JOptionPane.YES_OPTION) { discardCurrentObject(throwAwayOnDiscard); return true; } else if (rv == JOptionPane.NO_OPTION) { return false; } } else { if (rv == JOptionPane.YES_OPTION) { return saveObject(); } else if (rv == JOptionPane.CANCEL_OPTION) { return false; } else if (rv == JOptionPane.NO_OPTION) { // NO means Discard discardCurrentObject(throwAwayOnDiscard); return true; } } } finally { doingDiscard = false; } } else { return true; } return isNewAndComplete; }
From source file:edmondskarp.Gui.EdmondsKarpGui.java
public void saveGraph() { int option2 = JOptionPane.NO_OPTION; File f = null;/* w ww. jav a2s. c o m*/ String str = null; while (option2 == JOptionPane.NO_OPTION) //Finche' non decido di salvare { //Visualizzo la finestra di dialogo int option = chooser.showSaveDialog(this); if (option == JFileChooser.APPROVE_OPTION) //Se ho premuto il tasto salva { try { //Recupero il file selezionato f = chooser.getSelectedFile(); //Recupero il path del file str = f.getCanonicalPath(); //Se il nome del file non contiene l'estensione, la aggiungo io a mano //Se il file esiste chiedo se lo voglio sovrascrivere if (f.exists()) { option2 = JOptionPane.showConfirmDialog(this, "Il file esiste gia'.\nLo vuoi sovrascrivere?", "Sovrascrittura", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); } else { option2 = JOptionPane.YES_OPTION; } } catch (IOException | HeadlessException ex) { } } else { option2 = JOptionPane.CANCEL_OPTION; } } if (option2 == JOptionPane.YES_OPTION) { try { controller.save(str); } catch (JSONException ex) { Logger.getLogger(EdmondsKarpGui.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:com.mirth.connect.client.ui.Frame.java
/** * A prompt to ask the user if he would like to save the changes made before leaving the page. *//* w w w . j a v a 2 s . co m*/ public boolean confirmLeave() { if (currentContentPage == channelPanel && isSaveEnabled()) { if (!channelPanel.confirmLeave()) { return false; } } else if ((currentContentPage == channelEditPanel || currentContentPage == channelEditPanel.transformerPane || currentContentPage == channelEditPanel.filterPane) && isSaveEnabled()) { int option = JOptionPane.showConfirmDialog(this, "Would you like to save the channel changes?"); if (option == JOptionPane.YES_OPTION) { if (!channelEditPanel.saveChanges()) { return false; } } else if (option == JOptionPane.CANCEL_OPTION || option == JOptionPane.CLOSED_OPTION) { return false; } } else if (currentContentPage == settingsPane && isSaveEnabled()) { int option = JOptionPane.showConfirmDialog(this, "Would you like to save the " + settingsPane.getCurrentSettingsPanel().getTabName() + " settings changes?"); if (option == JOptionPane.YES_OPTION) { if (!settingsPane.getCurrentSettingsPanel().doSave()) { return false; } } else if (option == JOptionPane.CANCEL_OPTION || option == JOptionPane.CLOSED_OPTION) { return false; } } else if (currentContentPage == alertEditPanel && isSaveEnabled()) { int option = JOptionPane.showConfirmDialog(this, "Would you like to save the alerts?"); if (option == JOptionPane.YES_OPTION) { if (!alertEditPanel.saveAlert()) { return false; } } else if (option == JOptionPane.CANCEL_OPTION || option == JOptionPane.CLOSED_OPTION) { return false; } } else if (currentContentPage == globalScriptsPanel && isSaveEnabled()) { int option = JOptionPane.showConfirmDialog(this, "Would you like to save the scripts?"); if (option == JOptionPane.YES_OPTION) { if (!doSaveGlobalScripts()) { return false; } } else if (option == JOptionPane.CANCEL_OPTION || option == JOptionPane.CLOSED_OPTION) { return false; } } else if (currentContentPage == codeTemplatePanel && isSaveEnabled()) { if (!codeTemplatePanel.confirmLeave()) { return false; } } setSaveEnabled(false); return true; }
From source file:GUI.MainWindow.java
public void addReference(JTree tree, JList list, Reference current) { DefaultMutableTreeNode node = ((DefaultMutableTreeNode) tree.getLastSelectedPathComponent()); if (node == null) { return;//from www . ja va 2 s . c o m } Object obj = node.getUserObject(); if (!(obj instanceof Vulnerability)) { return; // here be monsters, most likely in the merge tree } Vulnerability vuln = (Vulnerability) obj; DefaultListModel dlm = (DefaultListModel) list.getModel(); // Build Input Field and display it JTextField description = new JTextField(); JTextField url = new JTextField(); // If current is not null then pre-set the description and risk if (current != null) { description.setText(current.getDescription()); url.setText(current.getUrl()); } JLabel error = new JLabel( "A valid URL needs to be supplied including the protocol i.e. http://www.github.com"); error.setForeground(Color.red); Object[] message = { "Description:", description, "URL:", url }; String url_string = null; Reference newref = null; while (url_string == null) { int option = JOptionPane.showConfirmDialog(null, message, "Add Reference", JOptionPane.OK_CANCEL_OPTION); if (option == JOptionPane.OK_OPTION) { System.out.println("User clicked ok, validating data"); String ref_desc = description.getText(); String ref_url = url.getText(); if (!ref_desc.equals("") || !ref_url.equals("")) { // Both have values // Try to validate URL try { URL u = new URL(url.getText()); u.toURI(); url_string = url.getText(); // Causes loop to end with a valid url } catch (MalformedURLException ex) { url_string = null; //ex.printStackTrace(); } catch (URISyntaxException ex) { url_string = null; //ex.printStackTrace(); } } } else if (option == JOptionPane.CANCEL_OPTION || option == JOptionPane.CLOSED_OPTION) { System.out.println("User clicked cancel/close"); return; // ends the loop without making any chages } if (url_string == null) { // We need to show an error saying that the url failed to parse Object[] message2 = { error, "Description:", description, "URL:", url }; message = message2; } } // If you get here there is a valid reference URL and description Reference ref = new Reference(description.getText(), url.getText()); if (current == null) { // Add it to the vuln vuln.addReference(ref); // Add it to the GUI dlm.addElement(ref); System.out.println("Valid reference added: " + ref); } else { // Modify it in the vuln vuln.modifyReference(current, ref); // Update the GUI dlm.removeElement(current); dlm.addElement(ref); System.out.println("Valid reference modified: " + ref); } }
From source file:jeplus.JEPlusFrameMain.java
private void jMenuItemExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemExitActionPerformed // Save the project file before exit? String cfn = this.CurrentProjectFile; int n = JOptionPane.showConfirmDialog(this, "Do you want to save the current project to " + (cfn == null ? "file" : cfn) + " before exit?", "Save project", JOptionPane.YES_NO_CANCEL_OPTION); if (n == JOptionPane.CANCEL_OPTION) { return;/*w ww. j av a 2 s .c o m*/ } else if (n == JOptionPane.YES_OPTION) { this.jMenuItemSaveActionPerformed(null); } // Check opened files for (int i = TpnEditors.getTabCount() - 1; i >= 0; i--) { try { ((IFJEPlusEditorPanel) TpnEditors.getComponentAt(i)).closeTextPanel(); } catch (ClassCastException | NullPointerException cce) { } } // Save EnergyPlus settings String currentdate = SimpleDateFormat.getDateInstance(SimpleDateFormat.MEDIUM).format(new Date()); JEPlusConfig.getDefaultInstance().saveToFile("jEPlus configuration generated at " + currentdate); // Exit if (this.getFrameCloseOperation() == JEPlusFrameMain.EXIT_ON_CLOSE) { System.exit(-1); } else { this.dispose(); } }
From source file:jeplus.JEPlusFrameMain.java
private void jMenuItemToRelativeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemToRelativeActionPerformed if (Project != null) { // Project base String base;//from w w w .jav a 2s. c o m int resp = JOptionPane.showConfirmDialog(this, "<html><p>Relative path will be calculated against the location where the " + "project is saved. Do you want to save your project first?</p><p>Current location is: " + Project.getBaseDir() + " </p></html>", "Save project?", JOptionPane.YES_NO_CANCEL_OPTION); if (resp == JOptionPane.CANCEL_OPTION) { return; } else if (resp == JOptionPane.YES_OPTION) { this.jMenuItemSaveAsActionPerformed(null); } base = Project.getBaseDir(); // Weather file path String path = Project.resolveWeatherDir(); Project.setWeatherDir(RelativeDirUtil.getRelativePath(path, base, "/")); // idf file path path = Project.resolveIDFDir(); Project.setIDFDir(RelativeDirUtil.getRelativePath(path, base, "/")); // dck file path path = Project.resolveDCKDir(); Project.setDCKDir(RelativeDirUtil.getRelativePath(path, base, "/")); // rvi file path path = Project.resolveRVIDir(); Project.setRVIDir(RelativeDirUtil.getRelativePath(path, base, "/")); // output dir path = Project.resolveWorkDir(); Project.getExecSettings().setParentDir(RelativeDirUtil.getRelativePath(path, base, "/")); // update screen this.initProjectSection(); this.cboExecutionTypeActionPerformed(null); } }