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.jabref.gui.fieldeditors.FileListEditor.java
/** * Run a file download operation./*w w w . j a v a 2 s . c o m*/ */ private void downloadFile() { String bibtexKey = entryEditor.getEntry().getCiteKey(); if (bibtexKey == null) { int answer = JOptionPane.showConfirmDialog(frame, Localization.lang("This entry has no BibTeX key. Generate key now?"), Localization.lang("Download file"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (answer == JOptionPane.OK_OPTION) { ActionListener l = entryEditor.getGenerateKeyAction(); l.actionPerformed(null); bibtexKey = entryEditor.getEntry().getCiteKey(); } } DownloadExternalFile def = new DownloadExternalFile(frame, frame.getCurrentBasePanel().getBibDatabaseContext(), bibtexKey); try { def.download(this); } catch (IOException ex) { LOGGER.warn("Cannot download.", ex); } }
From source file:com.floreantpos.config.ui.TerminalConfigurationView.java
public void restartPOS() { JOptionPane optionPane = new JOptionPane(Messages.getString("TerminalConfigurationView.26"), //$NON-NLS-1$ JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, Application.getApplicationIcon(), new String[] { /*Messages.getString("TerminalConfigurationView.28"),*/Messages .getString("TerminalConfigurationView.30") }); //$NON-NLS-1$ //$NON-NLS-2$ Object[] optionValues = optionPane.getComponents(); for (Object object : optionValues) { if (object instanceof JPanel) { JPanel panel = (JPanel) object; Component[] components = panel.getComponents(); for (Component component : components) { if (component instanceof JButton) { component.setPreferredSize(new Dimension(100, 80)); JButton button = (JButton) component; button.setPreferredSize(PosUIManager.getSize(100, 50)); }/*from w ww . j a va 2 s .c om*/ } } } JDialog dialog = optionPane.createDialog(Application.getPosWindow(), Messages.getString("TerminalConfigurationView.31")); //$NON-NLS-1$ dialog.setIconImage(Application.getApplicationIcon().getImage()); dialog.setLocationRelativeTo(Application.getPosWindow()); dialog.setVisible(true); Object selectedValue = (String) optionPane.getValue(); if (selectedValue != null) { if (selectedValue.equals(Messages.getString("TerminalConfigurationView.28"))) { //$NON-NLS-1$ try { Main.restart(); } catch (IOException | InterruptedException | URISyntaxException e) { } } else { } } }
From source file:de.huxhorn.lilith.swing.preferences.PreferencesDialog.java
public void deleteAllLogs() { String dialogTitle = "Delete all log files?"; String message = "This deletes *all* log files, even the Lilith logs and the global logs!\nDelete all log files right now?"; int result = JOptionPane.showConfirmDialog(this, message, dialogTitle, JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); // TODO: add "Show in Finder/Explorer" button if running on Mac/Windows if (JOptionPane.OK_OPTION != result) { return;/*w w w . j av a 2 s . co m*/ } mainFrame.deleteAllLogs(); }
From source file:gui.DownloadPanel.java
public void actionClearAllCompleted() { int action = JOptionPane.showConfirmDialog(parent, "Do you realy want to delete all completed files?", "Confirm delete all", JOptionPane.OK_CANCEL_OPTION); if (action == JOptionPane.OK_OPTION) { List<Download> selectedDownloads = downloadsTableModel.getDownloadsByStatus(DownloadStatus.COMPLETE); clearing = true;//from ww w. j a v a2s. com downloadsTableModel.clearDownloads(selectedDownloads); downloadList.removeAll(selectedDownloads); clearing = false; try { for (Download download : selectedDownloads) { if (selectedDownload == download) selectedDownload = null; DownloadDialog downloadDialog = getDownloadDialogByDownload(download); downloadDialogs.remove(downloadDialog); downloadDialog.removeDownloadInfoListener(this); downloadDialog.dispose(); databaseController.delete(download.getId()); FileUtils.forceDelete(new File( download.getDownloadRangePath() + File.separator + download.getDownloadName())); // todo must again } } catch (SQLException | IOException e) { e.printStackTrace(); } tableSelectionChanged(); } }
From source file:be.fedict.eid.tsl.tool.TslInternalFrame.java
@Override public void actionPerformed(ActionEvent event) { JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogTitle("Save Signer Certificate"); int result = fileChooser.showSaveDialog(this); if (JFileChooser.APPROVE_OPTION == result) { File file = fileChooser.getSelectedFile(); if (file.exists()) { int confirmResult = JOptionPane.showConfirmDialog(this, "File already exists.\n" + file.getAbsolutePath() + "\n" + "Overwrite file?", "Overwrite", JOptionPane.OK_CANCEL_OPTION); if (JOptionPane.CANCEL_OPTION == confirmResult) { return; }// w w w .j a v a2 s . c o m } try { FileUtils.writeByteArrayToFile(file, this.signerCertificate.getEncoded()); } catch (Exception e) { throw new RuntimeException("error writing file: " + e.getMessage(), e); } } }
From source file:be.ac.ua.comp.scarletnebula.gui.windows.GUI.java
public void terminateSelectedServers() { final Collection<Server> servers = serverList.getSelectedServers(); if (servers.isEmpty()) { return;//from www . j a v a2 s . co m } final String deleteMessage = "You are about to terminate " + servers.size() + " server(s). \n" + "Terminating a server will permanently destroy the server. This operation cannot be undone.\n\n" + "Do you wish to proceed?"; final String deleteTitle = "Terminate " + servers.size() + " server(s)"; final String buttonString = deleteTitle; final int result = JOptionPane.showOptionDialog(this, deleteMessage, deleteTitle, JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, Arrays.asList(buttonString, "Cancel").toArray(), "Cancel"); if (result != JOptionPane.OK_OPTION) { return; } (new SwingWorkerWithThrobber<Exception, Object>( newThrobber("Terminating server" + ((servers.size() > 1) ? "s" : ""))) { @Override protected Exception doInBackground() throws Exception { for (final Server server : servers) { try { server.terminate(); server.refreshUntilServerHasState(VmState.TERMINATED); } catch (final Exception e) { return e; } } return null; } @Override public void done() { try { final Exception result = get(); if (result != null) { log.error(result); error(result); } } catch (final Exception ignore) { } } }).execute(); }
From source file:SuitaDetails.java
public void showSuiteLib() { JScrollPane jScrollPane1 = new JScrollPane(); JList jList1 = new JList(); JPanel libraries = new JPanel(); jScrollPane1.setViewportView(jList1); GroupLayout layout = new GroupLayout(libraries); libraries.setLayout(layout);/*from w ww . j a v a2 s . co m*/ layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE)); layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)); try { Object[] s = (Object[]) RunnerRepository.getRPCClient().execute("getLibrariesList", new Object[] { RunnerRepository.user }); String[] libs = new String[s.length]; for (int i = 0; i < s.length; i++) { libs[i] = s[i].toString(); } ArrayList<Integer> ind = new ArrayList<Integer>(); jList1.setModel(new DefaultComboBoxModel(libs)); if (parent.getLibs() != null) { for (String st : parent.getLibs()) { for (int i = 0; i < libs.length; i++) { if (libs[i].equals(st)) { ind.add(new Integer(i)); } } } int[] indices = new int[ind.size()]; for (int i = 0; i < ind.size(); i++) { indices[i] = ind.get(i); } jList1.setSelectedIndices(indices); } } catch (Exception e) { System.out.println("There was an error on calling getLibrariesList on CE"); e.printStackTrace(); } int resp = (Integer) CustomDialog.showDialog(libraries, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, RunnerRepository.window, "Libraries", null); if (resp == JOptionPane.OK_OPTION) { Object[] val = jList1.getSelectedValues(); String[] libs = new String[val.length]; for (int s = 0; s < val.length; s++) { libs[s] = val[s].toString(); } parent.setLibs(libs); } }
From source file:ca.canuckcoding.wosqi.FeedViewer.java
private void install() { int tab = jTabbedPane2.getSelectedIndex(); ArrayList<PackageEntry> pkgList = getInstallList(selected[tab]); String msg = "<html><body width=\"300px\">" + MessageFormat .format(bundle.getString("DEPENDANCY_INSTALL_WARNING"), new Object[] { selected[tab].name }) + "\n"; ArrayList installList = new ArrayList(); for (int i = 0; i < pkgList.size(); i++) { PackageEntry curr = pkgList.get(i); if (!pkgMgr.isInstalled(curr)) { if (!curr.id.equals(selected[tab].id)) { msg += "\n" + curr.name; }/*w w w . ja v a2 s . c om*/ installList.add(curr.getDownloadUrl()); } } if (installList.size() > 1) { if (JOptionPane.showConfirmDialog(rootPane, msg, bundle.getString("WARNING"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) { doInstall(tab, installList); } } else { doInstall(tab, installList); } }
From source file:be.agiv.security.demo.Main.java
private void showPreferences() { JTabbedPane tabbedPane = new JTabbedPane(); GridBagLayout proxyGridBagLayout = new GridBagLayout(); GridBagConstraints proxyGridBagConstraints = new GridBagConstraints(); JPanel proxyPanel = new JPanel(proxyGridBagLayout) { private static final long serialVersionUID = 1L; @Override/*from w ww . java 2s . c om*/ public Insets getInsets() { return new Insets(10, 10, 10, 10); } }; tabbedPane.addTab("Proxy", proxyPanel); JCheckBox proxyEnableCheckBox = new JCheckBox("Enable proxy", this.proxyEnable); proxyGridBagConstraints.gridx = 0; proxyGridBagConstraints.gridy = 0; proxyGridBagConstraints.anchor = GridBagConstraints.WEST; proxyGridBagConstraints.ipadx = 5; proxyGridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; proxyGridBagLayout.setConstraints(proxyEnableCheckBox, proxyGridBagConstraints); proxyPanel.add(proxyEnableCheckBox); proxyGridBagConstraints.gridwidth = 1; JLabel proxyHostLabel = new JLabel("Host:"); proxyGridBagConstraints.gridx = 0; proxyGridBagConstraints.gridy++; proxyGridBagLayout.setConstraints(proxyHostLabel, proxyGridBagConstraints); proxyPanel.add(proxyHostLabel); JTextField proxyHostTextField = new JTextField(this.proxyHost, 20); proxyGridBagConstraints.gridx++; proxyGridBagLayout.setConstraints(proxyHostTextField, proxyGridBagConstraints); proxyPanel.add(proxyHostTextField); JLabel proxyPortLabel = new JLabel("Port:"); proxyGridBagConstraints.gridx = 0; proxyGridBagConstraints.gridy++; proxyGridBagLayout.setConstraints(proxyPortLabel, proxyGridBagConstraints); proxyPanel.add(proxyPortLabel); JTextField proxyPortTextField = new JTextField(Integer.toString(this.proxyPort), 8); proxyGridBagConstraints.gridx++; proxyGridBagLayout.setConstraints(proxyPortTextField, proxyGridBagConstraints); proxyPanel.add(proxyPortTextField); JLabel proxyTypeLabel = new JLabel("Type:"); proxyGridBagConstraints.gridx = 0; proxyGridBagConstraints.gridy++; proxyGridBagLayout.setConstraints(proxyTypeLabel, proxyGridBagConstraints); proxyPanel.add(proxyTypeLabel); JComboBox proxyTypeComboBox = new JComboBox(new Object[] { Proxy.Type.HTTP, Proxy.Type.SOCKS }); proxyTypeComboBox.setSelectedItem(this.proxyType); proxyGridBagConstraints.gridx++; proxyGridBagLayout.setConstraints(proxyTypeComboBox, proxyGridBagConstraints); proxyPanel.add(proxyTypeComboBox); int dialogResult = JOptionPane.showConfirmDialog(this, tabbedPane, "Preferences", JOptionPane.OK_CANCEL_OPTION); if (dialogResult == JOptionPane.CANCEL_OPTION) { return; } this.statusBar.setStatus("Applying new preferences..."); this.proxyHost = proxyHostTextField.getText(); this.proxyPort = Integer.parseInt(proxyPortTextField.getText()); this.proxyType = (Proxy.Type) proxyTypeComboBox.getSelectedItem(); this.proxyEnable = proxyEnableCheckBox.isSelected(); }
From source file:strobe.spectroscopy.StrobeSpectroscopy.java
private void btnSetZeroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSetZeroActionPerformed int result = JOptionPane.showConfirmDialog(this, OPTION_PANE_TEXT, btnSetZero.getText(), JOptionPane.OK_CANCEL_OPTION); if (result == JOptionPane.OK_OPTION) { //Get a noise current level and assign it to darkCurrent variable return;/*from w ww. j av a 2 s . c o m*/ } }