List of usage examples for javax.swing JOptionPane OK_CANCEL_OPTION
int OK_CANCEL_OPTION
To view the source code for javax.swing JOptionPane OK_CANCEL_OPTION.
Click Source Link
showConfirmDialog
. From source file:net.sf.maltcms.chromaui.ui.paintScales.PaintScaleDialogAction.java
/** * * @return//from w w w . j av a 2 s . co m */ public PaintScale showPaintScaleDialog() { if (this.psp == null) { this.psp = new PaintScalePanel(this.ps, this.alpha, this.beta); } int val = JOptionPane.showConfirmDialog(this.parent, psp, "Select Color Scale", JOptionPane.OK_CANCEL_OPTION); if (val == JOptionPane.OK_OPTION) { this.ps = psp.getPaintScale(); } if (this.ps == null) { this.ps = psp.getDefaultPaintScale(); } return this.ps; }
From source file:eu.ggnet.dwoss.redtape.action.StateTransitionAction.java
@Override public void actionPerformed(ActionEvent e) { //TODO: All the extra checks for hints don't feel like the optimum //Invoice//from w ww. j a v a2 s . c o m if (((RedTapeStateTransition) transition).getHints() .contains(RedTapeStateTransition.Hint.CREATES_INVOICE)) { int confirmInvoice = JOptionPane.showOptionDialog(parent, "Eine Rechnung wird unwiederruflich erstellt. Mchten Sie fortfahren?", "Rechnungserstellung", JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, null, null); if (confirmInvoice == JOptionPane.CANCEL_OPTION) return; } //Cancel if (((RedTapeStateTransition) transition).equals(RedTapeStateTransitions.CANCEL)) { int confirmInvoice = JOptionPane.showOptionDialog(parent, "Der Vorgang wird storniert.\nMchten Sie fortfahren?", "Abbrechen des Vorganges", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE, null, null, null); if (confirmInvoice == JOptionPane.NO_OPTION) return; } if (((RedTapeStateTransition) transition).getHints() .contains(RedTapeStateTransition.Hint.ADDS_SETTLEMENT)) { SettlementViewCask view = new SettlementViewCask(); OkCancelDialog<SettlementViewCask> dialog = new OkCancelDialog<>(parent, "Zahlung hinterlegen", view); dialog.setVisible(true); if (dialog.getCloseType() == CloseType.OK) { for (Document.Settlement settlement : view.getSettlements()) { cdoc.getDocument().add(settlement); } } else { return; } } if (((RedTapeStateTransition) transition).getHints() .contains(RedTapeStateTransition.Hint.UNIT_LEAVES_STOCK)) { for (Position p : cdoc.getDocument().getPositions(PositionType.PRODUCT_BATCH).values()) { //TODO not the best but fastest solution for now, this must be changed later if (StringUtils.isBlank(p.getRefurbishedId())) { if (JOptionPane.showConfirmDialog(parent, "Der Vorgang enthlt Neuware, wurden alle Seriennummern erfasst?", "Bitte verifizieren", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.CANCEL_OPTION) return; } } } Dossier d = lookup(RedTapeWorker.class).stateChange(cdoc, transition, lookup(Guardian.class).getUsername()) .getDossier(); controller.reloadSelectionOnStateChange(d); }
From source file:com.sun.jersey.client.apache.config.DefaultCredentialsProvider.java
public Credentials getCredentials(AuthScheme scheme, String host, int port, boolean proxy) throws CredentialsNotAvailableException { if (scheme == null) { return null; }// w w w . j a v a2 s .c o m try { JTextField userField = new JTextField(); JPasswordField passwordField = new JPasswordField(); int response; if (scheme instanceof NTLMScheme) { JTextField domainField = new JTextField(); Object[] msg = { host + ":" + port + " requires Windows authentication", "Domain", domainField, "User Name", userField, "Password", passwordField }; response = JOptionPane.showConfirmDialog(null, msg, "Authenticate", JOptionPane.OK_CANCEL_OPTION); if ((response == JOptionPane.CANCEL_OPTION) || (response == JOptionPane.CLOSED_OPTION)) { throw new CredentialsNotAvailableException("User cancled windows authentication."); } return new NTCredentials(userField.getText(), new String(passwordField.getPassword()), host, domainField.getText()); } else if (scheme instanceof RFC2617Scheme) { Object[] msg = { host + ":" + port + " requires authentication with the realm '" + scheme.getRealm() + "'", "User Name", userField, "Password", passwordField }; response = JOptionPane.showConfirmDialog(null, msg, "Authenticate", JOptionPane.OK_CANCEL_OPTION); if ((response == JOptionPane.CANCEL_OPTION) || (response == JOptionPane.CLOSED_OPTION)) { throw new CredentialsNotAvailableException("User cancled windows authentication."); } return new UsernamePasswordCredentials(userField.getText(), new String(passwordField.getPassword())); } else { throw new CredentialsNotAvailableException( "Unsupported authentication scheme: " + scheme.getSchemeName()); } } catch (IOException ioe) { throw new CredentialsNotAvailableException(ioe.getMessage(), ioe); } }
From source file:com.cmsoftware.keyron.vista.Login.java
/** * Operaciones de verificacin de actualizacin de acuerdo a la * configuracin./* ww w . j av a2 s . c o m*/ */ private void verificarActualizacion() { new Thread(() -> { if (new AplicacionFunciones().verificarActualizacion()) { String mensaje = "Hay una nueva versin del programa. Qu desea hacer?"; String[] opciones = { "Descargar e instalar", "Ms informacin" }; int respuesta = JOptionPane.showOptionDialog(null, mensaje, "Confirmar Operacin - Keyron", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, opciones, 0); if (respuesta == 0) { new EsperarDescarga(null, true, "Iniciando descarga...").setVisible(true); } else if (respuesta == 1) { new InformacionNuevaVersion(null, true).setVisible(true); } } }).start(); }
From source file:latexstudio.editor.DbxFileActions.java
/** * Shows a .tex files list from user's dropbox and opens the selected one * * @return List, that contatins user's .tex files from his dropbox; can be * empty//w ww.j a va 2 s . c o m */ public void openFromDropbox(DropboxRevisionsTopComponent drtc, RevisionDisplayTopComponent revtc) { List<DbxEntryDto> dbxEntries = getDbxTexEntries(DbxUtil.getDbxClient()); if (!dbxEntries.isEmpty()) { JList<DbxEntryDto> list = new JList(dbxEntries.toArray()); list.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION); int option = JOptionPane.showConfirmDialog(null, list, "Open file from Dropbox", JOptionPane.OK_CANCEL_OPTION); if (option == JOptionPane.OK_OPTION && !list.isSelectionEmpty()) { DbxEntryDto entry = list.getSelectedValue(); String localPath = ApplicationUtils.getAppDirectory() + File.separator + entry.getName(); File outputFile = DbxUtil.downloadRemoteFile(entry, localPath); revtc.close(); drtc.updateRevisionsList(entry.getPath()); drtc.open(); drtc.requestActive(); String content = FileService.readFromFile(outputFile.getAbsolutePath()); etc.setEditorContent(content); etc.setCurrentFile(outputFile); etc.setDbxState(new DbxState(entry.getPath(), entry.getRevision())); etc.setModified(false); etc.setPreviewDisplayed(false); } } else { JOptionPane.showMessageDialog(etc, "No .tex files found!", "Error", JOptionPane.ERROR_MESSAGE); } }
From source file:hudson.lifecycle.WindowsSlaveInstaller.java
/** * Called when the install menu is selected *//*from www.j a v a 2 s .c o m*/ public void actionPerformed(ActionEvent e) { int r = JOptionPane.showConfirmDialog(dialog, "This will install a slave agent as a Windows service,\n" + "so that this slave will connect to Hudson as soon as the machine boots.\n" + "Do you want to proceed with installation?", Messages.WindowsInstallerLink_DisplayName(), JOptionPane.OK_CANCEL_OPTION); if (r != JOptionPane.OK_OPTION) return; if (!DotNet.isInstalled(2, 0)) { JOptionPane.showMessageDialog(dialog, ".NET Framework 2.0 or later is required for this feature", Messages.WindowsInstallerLink_DisplayName(), JOptionPane.ERROR_MESSAGE); return; } final File dir = new File(rootDir); try { final File slaveExe = new File(dir, "hudson-slave.exe"); FileUtils.copyURLToFile(getClass().getResource("/windows-service/hudson.exe"), slaveExe); // write out the descriptor URL jnlp = new URL(engine.getHudsonUrl(), "computer/" + engine.slaveName + "/slave-agent.jnlp"); String xml = generateSlaveXml(System.getProperty("java.home") + "\\bin\\java.exe", "-jnlpUrl " + jnlp.toExternalForm()); FileUtils.writeStringToFile(new File(dir, "hudson-slave.xml"), xml, "UTF-8"); // copy slave.jar URL slaveJar = new URL(engine.getHudsonUrl(), "jnlpJars/remoting.jar"); File dstSlaveJar = new File(dir, "slave.jar").getCanonicalFile(); if (!dstSlaveJar.exists()) // perhaps slave.jar is already there? FileUtils.copyURLToFile(slaveJar, dstSlaveJar); // install as a service ByteArrayOutputStream baos = new ByteArrayOutputStream(); StreamTaskListener task = new StreamTaskListener(baos); r = new LocalLauncher(task).launch().cmds(slaveExe, "install").stdout(task).pwd(dir).join(); if (r != 0) { JOptionPane.showMessageDialog(dialog, baos.toString(), "Error", JOptionPane.ERROR_MESSAGE); return; } r = JOptionPane.showConfirmDialog(dialog, "Installation was successful. Would you like to\n" + "Stop this slave agent and start the newly installed service?", Messages.WindowsInstallerLink_DisplayName(), JOptionPane.OK_CANCEL_OPTION); if (r != JOptionPane.OK_OPTION) return; // let the service start after we close our connection, to avoid conflicts Runtime.getRuntime().addShutdownHook(new Thread("service starter") { public void run() { try { StreamTaskListener task = new StreamTaskListener(System.out); int r = new LocalLauncher(task).launch().cmds(slaveExe, "start").stdout(task).pwd(dir) .join(); task.getLogger() .println(r == 0 ? "Successfully started" : "start service failed. Exit code=" + r); } catch (IOException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } } }); System.exit(0); } catch (Exception t) { StringWriter sw = new StringWriter(); t.printStackTrace(new PrintWriter(sw)); JOptionPane.showMessageDialog(dialog, sw.toString(), "Error", JOptionPane.ERROR_MESSAGE); } }
From source file:nosqltools.MainForm.java
/** * Creates new form MainForm and sets the necessary properties for the main * form/*from w ww .j a va 2 s .com*/ */ public MainForm() { Image img = null; try { img = ImageIO.read(new File("resources/mongoicon.png")); } catch (IOException e) { } this.setIconImage(img); initComponents(); setExtendedState(JFrame.MAXIMIZED_BOTH); fc.setFileFilter(filter); textArea = new RSyntaxTextArea(20, 60); textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JSON); textArea.setCodeFoldingEnabled(true); textArea.setAntiAliasingEnabled(true); Table_JSON.addMouseListener(new java.awt.event.MouseAdapter() { @Override public void mouseClicked(java.awt.event.MouseEvent evt) { int row = Table_JSON.rowAtPoint(evt.getPoint()); int col = Table_JSON.columnAtPoint(evt.getPoint()); JOptionPane.showMessageDialog(null, "Value in the cell clicked :" + " " + Table_JSON.getValueAt(row, col).toString()); if (json_util.isArray(Table_JSON.getValueAt(row, col).toString())) { if (JOptionPane.showConfirmDialog(null, "View the array as a table:", "VIEW", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.YES_OPTION) { Panel_Views.setEnabled(false); Panel_Connections.setEnabled(false); jMenuBar1.setEnabled(false); if (row >= 0 && col >= 0) { TableForm tableForm = new TableForm(Table_JSON.getValueAt(row, col).toString()); } } } } }); RTextScrollPane sp = new RTextScrollPane(textArea); sp.setFoldIndicatorEnabled(true); Panel_Text.add(sp); Save_File.setEnabled(false); Panel_Text.setVisible(false); Panel_Table.setVisible(false); Panel_Hierarchical.setVisible(false); Panel_Compare.setVisible(false); Panel_Compare_Upper.setVisible(false); Panel_Connect.setVisible(false); util.changeTextAreaTheme(textArea); }
From source file:SimpleAuthenticator.java
protected PasswordAuthentication getPasswordAuthentication() { // given a prompt? String prompt = getRequestingPrompt(); if (prompt == null) prompt = "Please login..."; // protocol/* w w w . jav a2 s . c o m*/ String protocol = getRequestingProtocol(); if (protocol == null) protocol = "Unknown protocol"; // get the host String host = null; InetAddress inet = getRequestingSite(); if (inet != null) host = inet.getHostName(); if (host == null) host = "Unknown host"; // port String port = ""; int portnum = getRequestingPort(); if (portnum != -1) port = ", port " + portnum + " "; // Build the info string String info = "Connecting to " + protocol + " mail service on host " + host + port; //JPanel d = new JPanel(); // XXX - for some reason using a JPanel here causes JOptionPane // to display incorrectly, so we workaround the problem using // an anonymous JComponent. JComponent d = new JComponent() { }; GridBagLayout gb = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); d.setLayout(gb); c.insets = new Insets(2, 2, 2, 2); c.anchor = GridBagConstraints.WEST; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 0.0; d.add(constrain(new JLabel(info), gb, c)); d.add(constrain(new JLabel(prompt), gb, c)); c.gridwidth = 1; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.NONE; c.weightx = 0.0; d.add(constrain(new JLabel("Username:"), gb, c)); c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1.0; String user = getDefaultUserName(); JTextField username = new JTextField(user, 20); d.add(constrain(username, gb, c)); c.gridwidth = 1; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.EAST; c.weightx = 0.0; d.add(constrain(new JLabel("Password:"), gb, c)); c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1.0; JPasswordField password = new JPasswordField("", 20); d.add(constrain(password, gb, c)); // XXX - following doesn't work if (user != null && user.length() > 0) password.requestFocus(); else username.requestFocus(); int result = JOptionPane.showConfirmDialog(frame, d, "Login", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (result == JOptionPane.OK_OPTION) return new PasswordAuthentication(username.getText(), password.getText()); else return null; }
From source file:org.cds06.speleograph.graph.SeriesMenu.java
private JPopupMenu createPopupMenuForSeries(final Series series) { if (series == null) return new JPopupMenu(); final JPopupMenu menu = new JPopupMenu(series.getName()); menu.removeAll();/*from w w w . j a v a 2 s.co m*/ menu.add(new AbstractAction() { { putValue(NAME, "Renommer la srie"); } @Override public void actionPerformed(ActionEvent e) { menu.setVisible(false); String newName = ""; while (newName == null || newName.equals("")) { newName = (String) JOptionPane.showInputDialog(application, "Entrez un nouveau nom pour la srie", null, JOptionPane.QUESTION_MESSAGE, null, null, series.getName()); } series.setName(newName); } }); if (series.hasOwnAxis()) { menu.add(new AbstractAction() { { putValue(NAME, "Supprimer l'axe spcifique"); } @Override public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(application, "tes vous sr de vouloir supprimer cet axe ?", "Confirmation", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { series.setAxis(null); } } }); } else { menu.add(new JMenuItem(new AbstractAction() { { putValue(NAME, "Crer un axe spcifique pour la srie"); } @Override public void actionPerformed(ActionEvent e) { String name = JOptionPane.showInputDialog(application, "Quel titre pour cet axe ?", series.getAxis().getLabel()); if (name == null || "".equals(name)) return; // User has canceled series.setAxis(new NumberAxis(name)); } })); } menu.add(new SetTypeMenu(series)); if (series.isWater()) { menu.addSeparator(); menu.add(new SumOnPeriodAction(series)); menu.add(new CreateCumulAction(series)); } if (series.isWaterCumul()) { menu.addSeparator(); menu.add(new SamplingAction(series)); } if (series.isPressure()) { menu.addSeparator(); menu.add(new CorrelateAction(series)); menu.add(new WaterHeightAction(series)); } menu.addSeparator(); menu.add(new AbstractAction() { { String name; if (series.canUndo()) name = "Annuler " + series.getItemsName(); else name = series.getLastUndoName(); putValue(NAME, name); if (series.canUndo()) setEnabled(true); else { setEnabled(false); } } @Override public void actionPerformed(ActionEvent e) { series.undo(); } }); menu.add(new AbstractAction() { { String name; if (series.canRedo()) { name = "Refaire " + series.getNextRedoName(); setEnabled(true); } else { name = series.getNextRedoName(); setEnabled(false); } putValue(NAME, name); } @Override public void actionPerformed(ActionEvent e) { series.redo(); } }); menu.add(new AbstractAction() { { putValue(NAME, I18nSupport.translate("menus.serie.resetSerie")); if (series.canUndo()) setEnabled(true); else setEnabled(false); } @Override public void actionPerformed(ActionEvent e) { series.reset(); } }); menu.add(new LimitDateRangeAction(series)); menu.add(new HourSettingAction(series)); menu.addSeparator(); { JMenuItem deleteItem = new JMenuItem("Supprimer la srie"); deleteItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(application, "tes-vous sur de vouloir supprimer cette srie ?\n" + "Cette action est dfinitive.", "Confirmation", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) { series.delete(); } } }); menu.add(deleteItem); } menu.addSeparator(); { final JMenuItem up = new JMenuItem("Remonter dans la liste"), down = new JMenuItem("Descendre dans la liste"); ActionListener listener = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (e.getSource().equals(up)) { series.upSeriesInList(); } else { series.downSeriesInList(); } } }; up.addActionListener(listener); down.addActionListener(listener); if (series.isFirst()) { menu.add(down); } else if (series.isLast()) { menu.add(up); } else { menu.add(up); menu.add(down); } } menu.addSeparator(); { menu.add(new SeriesInfoAction(series)); } { JMenuItem colorItem = new JMenuItem("Couleur de la srie"); colorItem.addActionListener(new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { series.setColor(JColorChooser.showDialog(application, I18nSupport.translate("actions.selectColorForSeries"), series.getColor())); } }); menu.add(colorItem); } { JMenu plotRenderer = new JMenu("Affichage de la srie"); final ButtonGroup modes = new ButtonGroup(); java.util.List<DrawStyle> availableStyles; if (series.isMinMax()) { availableStyles = DrawStyles.getDrawableStylesForHighLow(); } else { availableStyles = DrawStyles.getDrawableStyles(); } for (final DrawStyle s : availableStyles) { final JRadioButtonMenuItem item = new JRadioButtonMenuItem(DrawStyles.getHumanCheckboxText(s)); item.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { if (item.isSelected()) series.setStyle(s); } }); modes.add(item); if (s.equals(series.getStyle())) { modes.setSelected(item.getModel(), true); } plotRenderer.add(item); } menu.add(plotRenderer); } menu.addSeparator(); menu.add(new AbstractAction() { { putValue(Action.NAME, "Fermer le fichier"); } @Override public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(application, "tes-vous sur de vouloir fermer toutes les sries du fichier ?", "Confirmation", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) { final File f = series.getOrigin(); for (final Series s : Series.getInstances().toArray(new Series[Series.getInstances().size()])) { if (s.getOrigin().equals(f)) s.delete(); } } } }); return menu; }
From source file:br.org.acessobrasil.silvinha.vista.panels.PainelSenha.java
public PainelSenha() { lblNome = new JLabel(GERAL.USUARIO); lblPass = new JLabel(GERAL.SENHA); txtName = new JTextField(10); txtPass = new JPasswordField(10); GridBagLayout bag = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); this.setLayout(bag); lblNome.setHorizontalAlignment(JLabel.RIGHT); gbc.fill = GridBagConstraints.BOTH; gbc.weightx = 1.0;// w w w .j a v a 2 s.c o m gbc.insets = new Insets(2, 10, 2, 10); this.add(lblNome, gbc); txtName.setAlignmentX(SwingConstants.WEST); txtName.addActionListener(new ActivateNextTextFieldListener(txtPass)); gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.insets = new Insets(2, 0, 2, 10); this.add(txtName, gbc); lblPass.setHorizontalAlignment(JLabel.RIGHT); gbc.fill = GridBagConstraints.BOTH; gbc.gridwidth = 1; gbc.weightx = 1.0; gbc.insets = new Insets(2, 10, 2, 10); this.add(lblPass, gbc); txtPass.setAlignmentX(SwingConstants.WEST); gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.insets = new Insets(2, 0, 2, 10); this.add(txtPass, gbc); setSize(300, 130); setLocation(300, 300); // this.setBackground(corDefault); op = new JOptionPane(this, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION); // op.setBackground(corDefault); }