List of usage examples for javax.swing JOptionPane CLOSED_OPTION
int CLOSED_OPTION
To view the source code for javax.swing JOptionPane CLOSED_OPTION.
Click Source Link
CANCEL_OPTION
or NO_OPTION
. From source file:org.planetcrypto.bitcoin.PlanetCryptoBitcoinUI.java
@SuppressWarnings("unchecked") private void ConfigurationRemoveMinerButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ConfigurationRemoveMinerButtonActionPerformed PlanetCryptoBitcoinUserConfiguration cfg = new PlanetCryptoBitcoinUserConfiguration(); String miner = ConfigurationRemoveMinerNameTextField.getText(); String ip = ConfigurationRemoveMinerIPTextField.getText(); int response; if (miner.isEmpty() & ip.isEmpty()) { JOptionPane.showMessageDialog(null, "Enter Miner Name or Miner IP!", "ERROR: NO PARAMETERS", JOptionPane.WARNING_MESSAGE); } else if (!miner.isEmpty()) { response = JOptionPane.showConfirmDialog(null, "Are you sure you want to delete " + miner + "?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.NO_OPTION) { return; //System.out.println("User opted out of deleting " + miner + "."); } else if (response == JOptionPane.CLOSED_OPTION) { return; //System.out.println("Dialog box was closed"); } else if (response == JOptionPane.YES_OPTION) { JOptionPane.showMessageDialog(null, cfg.removeMiner(miner, "name")); ConfigurationCurrentMinersTextPane.setText(cfg.currentMiners()); ConfigurationRemoveMinerNameTextField.setText(""); cfg.closeAll();/* w w w. j a v a 2 s . c o m*/ } } else if (!ip.isEmpty()) { response = JOptionPane.showConfirmDialog(null, "Are you sure you want to delete " + ip + "?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.NO_OPTION) { return; //System.out.println("User opted out of deleting " + ip + "."); } else if (response == JOptionPane.CLOSED_OPTION) { return; //System.out.println("Dialog box was closed"); } else if (response == JOptionPane.YES_OPTION) { JOptionPane.showMessageDialog(null, cfg.removeMiner(ip, "ip"), "SUCCESS!", JOptionPane.INFORMATION_MESSAGE); ConfigurationCurrentMinersTextPane.setText(cfg.currentMiners()); ConfigurationRemoveMinerIPTextField.setText(""); cfg.closeAll(); } } existing_miners = currentMiners(); ArrayList<String> miners = new ArrayList<>(); Map<Integer, HashMap<String, String>> current_miners = cfg.getMiners(); //jComboBox1. if (current_miners.get(0) == null) { miners.add("No Miners"); } else { for (int i = 0; i < current_miners.size(); i++) { miners.add(current_miners.get(i).get("name")); } } MinerSelectionBox.setModel(new javax.swing.DefaultComboBoxModel(miners.toArray())); MinerSelectionBox1.setModel(new javax.swing.DefaultComboBoxModel(miners.toArray())); MinerSelectionBox2.setModel(new javax.swing.DefaultComboBoxModel(miners.toArray())); MinerSelectionBox3.setModel(new javax.swing.DefaultComboBoxModel(miners.toArray())); CustomCommandMinerSelectionBox.setModel(new javax.swing.DefaultComboBoxModel(miners.toArray())); MinerSelectionBox5.setModel(new javax.swing.DefaultComboBoxModel(miners.toArray())); MinerSelectionForAlarmsBox.setModel(new javax.swing.DefaultComboBoxModel(miners.toArray())); MinerVitalStatsTextPanePropertyChange(null); }
From source file:org.planetcrypto.bitcoin.PlanetCryptoBitcoinUI.java
private void RemoveCoinbaseUsernameButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RemoveCoinbaseUsernameButtonActionPerformed // TODO add your handling code here: PlanetCryptoBitcoinUserConfiguration cfg = new PlanetCryptoBitcoinUserConfiguration(); existing_coinbase = cfg.getCoinbase(); if (existing_coinbase == null) { JOptionPane.showInternalMessageDialog(null, "No Users to delete", "ERROR!", JOptionPane.WARNING_MESSAGE); return;//from w ww .j ava 2 s. c om } String email = CoinbaseAPIUsernameTextField.getText(); int response; if (email.isEmpty()) { JOptionPane.showMessageDialog(null, "Please enter Coinbase Username", "ERROR: NO PARAMETERS", JOptionPane.WARNING_MESSAGE); } else if (!existing_coinbase.toString().contains(email)) { JOptionPane.showMessageDialog(null, "No such Coinbase Username: " + email + ".", "ERROR: NO SUCH USERNAME", JOptionPane.WARNING_MESSAGE); } else if (!email.isEmpty()) { response = JOptionPane.showConfirmDialog(null, "Are you sure you want to delete " + email + "?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.NO_OPTION) { return; //System.out.println("User opted out of deleting " + miner + "."); } else if (response == JOptionPane.CLOSED_OPTION) { return; //System.out.println("Dialog box was closed"); } else if (response == JOptionPane.YES_OPTION) { JOptionPane.showMessageDialog(null, cfg.removeCoinbase(email)); CoinbaseAPIUsernameTextField.setText(""); GenericInformationCoinbaseUserSelectionBox .setModel(new DefaultComboBoxModel(existingCoinbase().toArray())); CurrentCoinbaseConfigurationTextPanePropertyChange(null); cfg.closeAll(); } } }
From source file:org.sikuli.ide.SikuliIDE.java
private int askForSaveAll(String typ) { //TODO I18N//from w w w . j a va 2 s.c o m String warn = "Some scripts are not saved yet!"; String title = SikuliIDEI18N._I("dlgAskCloseTab"); String[] options = new String[3]; options[WARNING_DO_NOTHING] = typ + " immediately"; options[WARNING_ACCEPTED] = "Save all and " + typ; options[WARNING_CANCEL] = SikuliIDEI18N._I("cancel"); int ret = JOptionPane.showOptionDialog(this, warn, title, 0, JOptionPane.WARNING_MESSAGE, null, options, options[2]); if (ret == WARNING_CANCEL || ret == JOptionPane.CLOSED_OPTION) { return -1; } return ret; }
From source file:org.sikuli.ide.SikuliIDE.java
public void showExtensionsFrame() { // String warn = "You might proceed, if you\n" // + "- have some programming skills\n" // + "- read the docs about extensions\n" // + "- know what you are doing\n\n" // + "Otherwise you should press Cancel!"; String warn = "Not available yet - click what you like ;-)"; String title = "Need your attention!"; String[] options = new String[3]; options[WARNING_DO_NOTHING] = "OK"; options[WARNING_ACCEPTED] = "Be quiet!"; options[WARNING_CANCEL] = "Cancel"; int ret = JOptionPane.showOptionDialog(this, warn, title, 0, JOptionPane.WARNING_MESSAGE, null, options, options[2]);/*from ww w . ja va 2s . c o m*/ if (ret == WARNING_CANCEL || ret == JOptionPane.CLOSED_OPTION) { return; } if (ret == WARNING_ACCEPTED) { //TODO set prefs to be quiet on extensions warning } ; ExtensionManagerFrame extmg = ExtensionManagerFrame.getInstance(); if (extmg != null) { extmg.setVisible(true); } }
From source file:parsegui.Window.java
private void buyTicketActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buyTicketActionPerformed int ticketCount = 0; long phone = 0; //eventList.setSelectedItem(evt); String festSelection = (String) eventList.getSelectedItem(); String personName = (String) nameTextField.getText(); String email = (String) mailTextField.getText(); //ParseObject rel = new ParseObject("Attendee"); ParseObject aObj = new ParseObject("Attendee"); try {// w ww . j a v a 2 s .c o m int length = String.valueOf(phoneTextField.getText()).length(); if (length == 0 || length < 10 || length > 10) { JOptionPane.showConfirmDialog(null, "Please enter a valid 10 digit phone number", "Error", JOptionPane.CLOSED_OPTION); return; } else { phone = Long.parseLong(phoneTextField.getText()); } ticketCount = Integer.parseInt(ticketNoField.getText()); if (ticketCount <= 0) { JOptionPane.showConfirmDialog(null, "Number of tickets should be atleast 1", "Error", JOptionPane.CLOSED_OPTION); return; } } catch (NumberFormatException e) { System.out.println("Exception" + e); JOptionPane.showConfirmDialog(null, "Please fill all the fields", "Error", JOptionPane.CLOSED_OPTION); return; } int b = JOptionPane.showConfirmDialog(null, "Confirm " + ticketCount + " tickets", "Confirm", JOptionPane.OK_CANCEL_OPTION); if (b == 0) { System.out.println("Phone number: " + phone); System.out.println("number of tickets: " + ticketCount); System.out.println("name: " + personName); System.out.println("Email-ID: " + email); System.out.println("festival selected: " + festSelection); aObj.put("Name", personName); aObj.put("PhoneNo", phone); aObj.put("EmailID", email); aObj.put("Tickets_purchased", ticketCount); /* fest selection*/ ParseQuery festquery = new ParseQuery("Festival"); ParseObject festObj = new ParseObject("Festival"); // String id = festObj.getString("Rockathon");// id = null.. should be in loop nd use list/array System.out.println(eventList.getSelectedItem()); //festquery.whereEqualTo(festSelection, festObj.getString("Rockathon")); /* festquery.findInBackground(new FindCallback() { @Override public void done(List<ParseObject> objects, ParseException e) { if(e == null){ System.out.println("QUERRIED ATLAST!!!!"); } else{ System.out.println("NOOOOOOOOOO"); } } });*/ festquery.findInBackground(new FindCallback() { @Override public void done(List<ParseObject> objects, almonds.ParseException e) { if (e == null) { List<ParseObject> res = new ArrayList<>(objects); HashMap<String, String> hm = new HashMap<>(); System.out.println(res.size()); /*for (ParseObject re : res) { System.out.println("IDS: " + re.getString("Festival_name")); }*/ ParseObject re1 = new ParseObject("Festival"); for (ParseObject re : res) { System.out.println("festival name: " + re.getString("Festival_name") + " festivalID : " + re.getObjectId()); ; // n.add(re.getObjectId()); hm.put(re.getObjectId(), re.getString("Festival_name")); } if (hm.containsValue(festSelection)) { for (Map.Entry entry : hm.entrySet()) { if (festSelection.equals(entry.getValue())) { System.out.println("Selected festival key is " + entry.getKey()); } } } } else { System.out.println("error"); } } }); try { aObj.save(); } catch (ParseException ex) { Logger.getLogger(Window.class.getName()).log(Level.SEVERE, null, ex); JOptionPane.showConfirmDialog(null, "ERROR: " + ex, "Error", JOptionPane.OK_CANCEL_OPTION); } } else { return; } System.exit(0); }
From source file:pcgen.gui2.dialog.ExportDialog.java
private void maybeOpenFile(File file) { UIPropertyContext context = UIPropertyContext.getInstance(); String value = context.getProperty(UIPropertyContext.ALWAYS_OPEN_EXPORT_FILE); Boolean openFile = StringUtils.isEmpty(value) ? null : Boolean.valueOf(value); if (openFile == null) { JCheckBox checkbox = new JCheckBox(); checkbox.setText("Always perform this action"); JPanel message = PCGenFrame.buildMessageLabelPanel("Do you want to open " + file.getName() + "?", checkbox);/* ww w . java 2 s. c o m*/ int ret = JOptionPane.showConfirmDialog(this, message, "Select an Option", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (ret == JOptionPane.CLOSED_OPTION) { return; } openFile = BooleanUtils.toBoolean(ret, JOptionPane.YES_OPTION, JOptionPane.NO_OPTION); if (checkbox.isSelected()) { context.setBoolean(UIPropertyContext.ALWAYS_OPEN_EXPORT_FILE, openFile); } } if (!openFile) { return; } if (!Desktop.isDesktopSupported() || !Desktop.getDesktop().isSupported(Desktop.Action.OPEN)) { pcgenFrame.showErrorMessage("Cannot Open " + file.getName(), "Operating System does not support this operation"); return; } try { Desktop.getDesktop().open(file); } catch (IOException ex) { String message = "Failed to open " + file.getName(); pcgenFrame.showErrorMessage(Constants.APPLICATION_NAME, message); Logging.errorPrint(message, ex); } }
From source file:pl.kotcrab.arget.gui.ContactsPanel.java
public ContactsPanel(final Profile profile, MainWindowCallback callback) { this.profile = profile; setLayout(new BorderLayout()); table = new JTable(new ContactsTableModel(profile.contacts)); table.setDefaultRenderer(ContactInfo.class, new ContactsTableEditor(table, callback)); table.setDefaultEditor(ContactInfo.class, new ContactsTableEditor(table, callback)); table.setShowGrid(false);//from w w w . j a v a 2s . c o m table.setTableHeader(null); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setRowHeight(40); final JPopupMenu popupMenu = new JPopupMenu(); { JMenuItem menuModify = new JMenuItem("Modify"); JMenuItem menuDelete = new JMenuItem("Delete"); popupMenu.add(menuModify); popupMenu.add(menuDelete); menuModify.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String key = Base64.encodeBase64String(profile.rsa.getPublicKey().getEncoded()); new CreateContactDialog(MainWindow.instance, key, (ContactInfo) table.getValueAt(table.getSelectedRow(), 0)); ProfileIO.saveProfile(profile); updateContactsTable(); } }); menuDelete.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ContactInfo contact = (ContactInfo) table.getValueAt(table.getSelectedRow(), 0); if (contact.status == ContactStatus.CONNECTED_SESSION) { JOptionPane.showMessageDialog(MainWindow.instance, "This contact cannot be deleted because session is open.", "Error", JOptionPane.ERROR_MESSAGE); return; } int result = JOptionPane.showConfirmDialog(MainWindow.instance, "Are you sure you want to delete '" + contact.name + "'?", "Warning", JOptionPane.YES_NO_OPTION); if (result == JOptionPane.NO_OPTION || result == JOptionPane.CLOSED_OPTION) return; profile.contacts.remove(contact); ProfileIO.saveProfile(profile); updateContactsTable(); } }); } table.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (SwingUtilities.isRightMouseButton(e)) { Point p = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), table); int rowNumber = table.rowAtPoint(p); table.editCellAt(rowNumber, 0); table.getSelectionModel().setSelectionInterval(rowNumber, rowNumber); popupMenu.show(e.getComponent(), e.getX(), e.getY()); } } }); JScrollPane tableScrollPane = new JScrollPane(table); tableScrollPane.setBorder(new EmptyBorder(0, 0, 0, 0)); add(tableScrollPane, BorderLayout.CENTER); }
From source file:processing.app.Editor.java
/** * Check if the sketch is modified and ask user to save changes. * @return false if canceling the close/quit operation *//*from ww w. j a v a 2s . c om*/ protected boolean checkModified() { if (!sketch.isModified()) return true; // As of Processing 1.0.10, this always happens immediately. // http://dev.processing.org/bugs/show_bug.cgi?id=1456 toFront(); String prompt = I18n.format(_("Save changes to \"{0}\"? "), sketch.getName()); if (!OSUtils.isMacOS()) { int result = JOptionPane.showConfirmDialog(this, prompt, _("Close"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); switch (result) { case JOptionPane.YES_OPTION: return handleSave(true); case JOptionPane.NO_OPTION: return true; // ok to continue case JOptionPane.CANCEL_OPTION: case JOptionPane.CLOSED_OPTION: // Escape key pressed return false; default: throw new IllegalStateException(); } } else { // This code is disabled unless Java 1.5 is being used on Mac OS X // because of a Java bug that prevents the initial value of the // dialog from being set properly (at least on my MacBook Pro). // The bug causes the "Don't Save" option to be the highlighted, // blinking, default. This sucks. But I'll tell you what doesn't // suck--workarounds for the Mac and Apple's snobby attitude about it! // I think it's nifty that they treat their developers like dirt. // Pane formatting adapted from the quaqua guide // http://www.randelshofer.ch/quaqua/guide/joptionpane.html JOptionPane pane = new JOptionPane(_("<html> " + "<head> <style type=\"text/css\">" + "b { font: 13pt \"Lucida Grande\" }" + "p { font: 11pt \"Lucida Grande\"; margin-top: 8px }" + "</style> </head>" + "<b>Do you want to save changes to this sketch<BR>" + " before closing?</b>" + "<p>If you don't save, your changes will be lost."), JOptionPane.QUESTION_MESSAGE); String[] options = new String[] { _("Save"), _("Cancel"), _("Don't Save") }; pane.setOptions(options); // highlight the safest option ala apple hig pane.setInitialValue(options[0]); // on macosx, setting the destructive property places this option // away from the others at the lefthand side pane.putClientProperty("Quaqua.OptionPane.destructiveOption", new Integer(2)); JDialog dialog = pane.createDialog(this, null); dialog.setVisible(true); Object result = pane.getValue(); if (result == options[0]) { // save (and close/quit) return handleSave(true); } else if (result == options[2]) { // don't save (still close/quit) return true; } else { // cancel? return false; } } }
From source file:proyectoprestamos.DatosUsuario.java
private void EnviarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_EnviarActionPerformed numeroDni = dniUsuario.getText();//from w ww . ja v a2 s .co m if (esDni(numeroDni)) { int respuesta = JOptionPane.showConfirmDialog(null, "El prstamo se ha realizado correctamente", "Gracias", JOptionPane.CLOSED_OPTION); } else { JOptionPane.showMessageDialog(this, "El Dni introducido no es vlido, debe tener 8 dgitos", "Error", JOptionPane.ERROR_MESSAGE); } }
From source file:pt.lsts.neptus.mra.MRAFilesHandler.java
/** * Open LSF Log file//from w w w. j a v a 2 s .c o m * @param f * @return */ private boolean openLSF(File f) { mra.getBgp().block(true); mra.getBgp().setText(I18n.text("Loading LSF Data")); if (!f.exists()) { mra.getBgp().block(false); GuiUtils.errorMessage(mra, I18n.text("Invalid LSF file"), I18n.text("LSF file does not exist!")); return false; } final File lsfDir = f.getParentFile(); //IMCDefinition.pathToDefaults = ConfigFetch.getDefaultIMCDefinitionsLocation(); boolean alreadyConverted = false; if (lsfDir.isDirectory()) { if (new File(lsfDir, "mra/lsf.index").canRead()) alreadyConverted = true; } else if (new File(lsfDir, "mra/lsf.index").canRead()) alreadyConverted = true; if (alreadyConverted) { int option = GuiUtils.confirmDialogWithCancel(mra, I18n.text("Open Log"), I18n.text("This log seems to have already been indexed. Index again?")); if (option == JOptionPane.YES_OPTION) { try { FileUtils.deleteDirectory(new File(lsfDir, "mra")); } catch (Exception e) { NeptusLog.pub().error("Error while trying to delete mra/ folder", e); } } if (option == JOptionPane.CANCEL_OPTION || option == JOptionPane.CLOSED_OPTION) { mra.getBgp().block(false); return false; } } mra.getBgp().setText(I18n.text("Loading LSF Data")); try { LsfLogSource source = new LsfLogSource(f, new LsfIndexListener() { @Override public void updateStatus(String messageToDisplay) { mra.getBgp().setText(messageToDisplay); } }); updateMissionFilesOpened(f); mra.getBgp().setText(I18n.text("Starting interface")); openLogSource(source); mra.getBgp().setText(I18n.text("Done")); mra.getBgp().block(false); return true; } catch (Exception e) { mra.getBgp().block(false); e.printStackTrace(); GuiUtils.errorMessage(mra, I18n.text("Invalid LSF index"), I18n.text(e.getMessage())); return false; } }