List of usage examples for javax.swing JOptionPane OK_OPTION
int OK_OPTION
To view the source code for javax.swing JOptionPane OK_OPTION.
Click Source Link
From source file:org.zaproxy.zap.extension.customFire.ExtensionCustomFire.java
protected void showPolicyDialog(PolicyManagerDialog parent, String name) throws ConfigurationException { CustomScanPolicy policy;//from w w w. j av a 2 s . c o m if (name != null) { policy = this.getPolicyManager().getPolicy(name); } else { policy = this.getPolicyManager().getTemplatePolicy(); } PolicyDialog dialog = new PolicyDialog(this, parent, policy); dialog.initParam(getModel().getOptionsParam()); for (AbstractParamPanel panel : policyPanels) { dialog.addPolicyPanel(panel); } int result = dialog.showDialog(true); if (result == JOptionPane.OK_OPTION) { try { getModel().getOptionsParam().getConfig().save(); } catch (ConfigurationException ce) { //logger.error(ce.getMessage(), ce); getView().showWarningDialog(Constant.messages.getString("scanner.save.warning")); } } }
From source file:org.zaproxy.zap.extension.customFire.PolicyManagerDialog.java
private JButton getRemoveButton() { if (this.removeButton == null) { this.removeButton = new JButton( Constant.messages.getString("customFire.custom.policymgr.button.remove")); this.removeButton.setEnabled(false); this.removeButton.addActionListener(new ActionListener() { @Override/*www.j av a 2 s. c o m*/ public void actionPerformed(ActionEvent e) { String name = (String) getParamsModel().getValueAt(getParamsTable().getSelectedRow(), 0); if (name != null) { if (View.getSingleton().showConfirmDialog(PolicyManagerDialog.this, Constant.messages .getString("customFire.custom.policymgr.warn.delete")) == JOptionPane.OK_OPTION) { extension.getPolicyManager().deletePolicy(name); policyNamesChanged(); } } } }); } return this.removeButton; }
From source file:org.zaproxy.zap.extension.zest.dialogs.ZestRequestDialog.java
private JButton getRemoveButton() { if (this.removeButton == null) { this.removeButton = new JButton(Constant.messages.getString("zest.dialog.script.button.remove")); this.removeButton.setEnabled(false); final ZestRequestDialog parent = this; this.removeButton.addActionListener(new ActionListener() { @Override/*from w w w .j av a 2s . c o m*/ public void actionPerformed(ActionEvent e) { if (JOptionPane.OK_OPTION == View.getSingleton().showConfirmDialog(parent, Constant.messages.getString("zest.dialog.script.remove.confirm"))) { getCookieModel().remove(getCookiesTable().getSelectedRow()); } } }); } return this.removeButton; }
From source file:org.zaproxy.zap.view.ComponentMaximiserMouseListener.java
/** * Confirms, by asking the user, if the maximisation should be done. * <p>/*from w w w .jav a 2 s . c om*/ * After positive confirmation this method returns always {@code true}. * * @return {@code true} if the maximisation should be done, {@code false} otherwise. * @see #triggerMaximisation(Component) * @see OptionsParamView#getWarnOnTabDoubleClick() */ private boolean confirmMaximisation() { if (!viewOptions.getWarnOnTabDoubleClick()) { return true; } if (View.getSingleton().showConfirmDialog(DOUBLE_CLICK_WARN_MESSAGE) != JOptionPane.OK_OPTION) { return false; } viewOptions.setWarnOnTabDoubleClick(false); try { viewOptions.getConfig().save(); } catch (ConfigurationException e) { LOGGER.error(e.getMessage(), e); } return true; }
From source file:Panels.LocationPanel.java
public void locationFromInternetLabelMouseClicked(MouseEvent e) { try {/*from ww w . ja va 2 s .c o m*/ if (getLocationFromIP()) { this.locationFromInternet.setEnabled(true); this.locationFromInternet.setIcon(locationfromInternetIcon); int result = JOptionPane.showConfirmDialog(null, PropertiesHandler.getSingleton().getValue(1049) + " : " + country + "\n" + PropertiesHandler.getSingleton().getValue(1050) + " : " + city + "\n" + PropertiesHandler.getSingleton().getValue(1051) + " : " + longitude + "\n" + PropertiesHandler.getSingleton().getValue(1052) + " : " + latitude + "\n" + PropertiesHandler.getSingleton().getValue(1053) + " : " + timezone, PropertiesHandler.getSingleton().getValue(1049) + "-" + PropertiesHandler.getSingleton().getValue(1050) + "-" + PropertiesHandler.getSingleton().getValue(1051) + "-" + PropertiesHandler.getSingleton().getValue(1052), JOptionPane.OK_CANCEL_OPTION); if (result == JOptionPane.OK_OPTION) { UserConfig.getSingleton().setCountry(country); UserConfig.getSingleton().setCity(city); UserConfig.getSingleton().setLongitude(longitude); UserConfig.getSingleton().setLatitude(latitude); UserConfig.getSingleton().setTimezone(timezone); countriesModel.add(0, country); citiesModel.add(0, city); citiesList.setSelectedIndex(0); countriesList.setSelectedIndex(0); XmlHandler.getSingleton().addUserConfig(UserConfig.getSingleton()); longitudeValue.setText(longitude); latitudeValue.setText(latitude); timezoneValue.setText(timezone); } else { this.locationFromInternet.setEnabled(true); this.locationFromInternet.setIcon(locationfromInternetIcon); } } else { this.locationFromInternet.setEnabled(true); this.locationFromInternet.setIcon(locationfromInternetIcon); JOptionPane.showMessageDialog(null, PropertiesHandler.getSingleton().getValue(1104), PropertiesHandler.getSingleton().getValue(1069), JOptionPane.ERROR_MESSAGE); } } catch (Exception ex) { this.locationFromInternet.setEnabled(true); this.locationFromInternet.setIcon(locationfromInternetIcon); } }
From source file:picocash.Picocash.java
@Override protected void initialize(String[] arg0) { ServiceDiscover.getAll(IPicocashPersistenceManager.class); Services.setSelectedPersistenceMan(ServiceDiscover.getSingleton(IPicocashPersistenceManager.class)); Services.getSelectedPersistenceMan().setDatabaseName("test.mmoc"); try {//from ww w .j a v a 2 s . c o m Services.getSelectedPersistenceMan().initDB(); } catch (Exception ex) { log.fatal("Exception while restarting database:", ex); exit(); } PicocashIcons.init(); JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); addExitListener(new ExitListener() { @Override public boolean canExit(EventObject event) { if (changesAvailable) { int retValue = JOptionPane.showConfirmDialog(getMainFrame(), "Das sollte der Title sein", "und die Message", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (retValue == JOptionPane.OK_OPTION) { save(); } return retValue == JOptionPane.OK_OPTION || retValue == JOptionPane.CANCEL_OPTION; } return true; } @Override public void willExit(EventObject event) { Services.getSelectedPersistenceMan().close(); } }); super.initialize(arg0); }
From source file:pl.otros.logview.gui.actions.ConnectToSocketHubAppenderAction.java
private boolean chooseLogImporter() { DataConfiguration configuration = getOtrosApplication().getConfiguration(); List<Object> list1 = configuration.getList(ConfKeys.SOCKET_HUB_APPENDER_ADDRESSES); configuration.getInt(ConfKeys.SOCKET_HUB_APPENDER_ADDRESSES_MAX_COUNT, 20); Vector<String> recent = new Vector<String>(); for (Object o : list1) { recent.add(o.toString());/*from w w w . j a va 2 s. co m*/ } JXComboBox box = new JXComboBox(recent); box.setEditable(true); AutoCompleteDecorator.decorate(box); MigLayout migLayout = new MigLayout(); JPanel panel = new JPanel(migLayout); panel.add(new JLabel("Host name:port")); panel.add(box, "wrap, width 200:220:440"); while (true) { String[] options = { "Connect", "Cancel" }; int showConfirmDialog = JOptionPane.showOptionDialog(getOtrosApplication().getApplicationJFrame(), panel, "Enter host name and port", JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[0]); if (showConfirmDialog != JOptionPane.OK_OPTION) { return false; } try { String hostAndPortString = box.getSelectedItem().toString().trim(); socket = tryToConnectToSocket(configuration, hostAndPortString, SocketFactory.getDefault()); } catch (UnknownHostException e) { JOptionPane.showMessageDialog(panel, host + " is unknown host name", "Error", JOptionPane.ERROR_MESSAGE); continue; } catch (IOException e) { JOptionPane.showMessageDialog(panel, "Cannot connect to host " + host + ":" + port, "Error", JOptionPane.ERROR_MESSAGE); continue; } catch (NumberFormatException e) { JOptionPane.showMessageDialog(panel, "Can't parse port number.", "Error", JOptionPane.ERROR_MESSAGE); continue; } return true; } }
From source file:pl.otros.logview.gui.actions.StartSocketListener.java
private LogImporterAndPort chooseLogImporter() { Collection<LogImporter> elements = AllPluginables.getInstance().getLogImportersContainer().getElements(); LogImporter[] importers = elements.toArray(new LogImporter[0]); String[] names = new String[elements.size()]; for (int i = 0; i < names.length; i++) { names[i] = importers[i].getName(); }//from w w w. j ava2 s. c o m JComboBox box = new JComboBox(names); SpinnerNumberModel numberModel = new SpinnerNumberModel(50505, 1025, 65000, 1); JSpinner jSpinner = new JSpinner(numberModel); MigLayout migLayout = new MigLayout(); JPanel panel = new JPanel(migLayout); panel.add(new JLabel("Select log importer")); panel.add(box, "wrap"); panel.add(new JLabel("Select port")); panel.add(jSpinner, "span"); if (logReaders.size() > 0) { panel.add(new JLabel("Opened sockets"), "wrap, growx"); JTable jTable = new JTable(logReaders.size(), 2); jTable.getTableHeader().getColumnModel().getColumn(0).setHeaderValue("Log importer"); jTable.getTableHeader().getColumnModel().getColumn(1).setHeaderValue("Port"); int row = 0; for (SocketLogReader socketLogReader : logReaders) { jTable.setValueAt(socketLogReader.getLogImporter().getName(), row, 0); jTable.setValueAt(Integer.toString(socketLogReader.getPort()), row, 1); row++; } JScrollPane jScrollPane = new JScrollPane(jTable); panel.add(jScrollPane, "wrap, span"); } int showConfirmDialog = JOptionPane.showConfirmDialog(null, panel, "Choose log importer and port", JOptionPane.OK_CANCEL_OPTION); if (showConfirmDialog != JOptionPane.OK_OPTION) { return null; } return new LogImporterAndPort(importers[box.getSelectedIndex()], numberModel.getNumber().intValue()); }
From source file:pl.otros.vfs.browser.auth.AbstractUiUserAuthenticator.java
@Override public UserAuthenticationData requestAuthentication(Type[] types) { try {//from w w w . j a v a2s .c o m Runnable doRun = new Runnable() { @Override public void run() { if (saveCredentialsCheckBox == null) { saveCredentialsCheckBox = new JCheckBox(Messages.getMessage("authenticator.savePassword"), true); } JPanel authOptionPanel = getOptionsPanel(); JPanel panel = new JPanel(new BorderLayout()); panel.add(authOptionPanel); panel.add(saveCredentialsCheckBox, BorderLayout.SOUTH); String[] options = { Messages.getMessage("general.okButtonText"), Messages.getMessage("general.cancelButtonText") }; int showConfirmDialog = JOptionPane.showOptionDialog(null, panel, Messages.getMessage("authenticator.enterCredentials"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[0]); if (showConfirmDialog != JOptionPane.OK_OPTION) { throw new AuthorisationCancelledException("Authorization cancelled by user"); } data = new UserAuthenticationDataWrapper(); getAuthenticationData(data); } }; if (SwingUtilities.isEventDispatchThread()) { doRun.run(); } else { SwingUtilities.invokeAndWait(doRun); } } catch (Exception e) { if (Throwables.getRootCause(e) instanceof AuthorisationCancelledException) { throw (AuthorisationCancelledException) Throwables.getRootCause(e); } } return data; }
From source file:processing.app.Editor.java
/** * Checks to see if the sketch has been modified, and if so, * asks the user to save the sketch or cancel the export. * This prevents issues where an incomplete version of the sketch * would be exported, and is a fix for/*ww w . j av a2 s . com*/ * <A HREF="http://dev.processing.org/bugs/show_bug.cgi?id=157">Bug 157</A> */ protected boolean handleExportCheckModified() { if (!sketch.isModified()) return true; Object[] options = { _("OK"), _("Cancel") }; int result = JOptionPane.showOptionDialog(this, _("Save changes before export?"), _("Save"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (result == JOptionPane.OK_OPTION) { handleSave(true); } else { // why it's not CANCEL_OPTION is beyond me (at least on the mac) // but f-- it.. let's get this shite done.. //} else if (result == JOptionPane.CANCEL_OPTION) { statusNotice(_("Export canceled, changes must first be saved.")); //toolbar.clear(); return false; } return true; }