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:uk.nhs.cfh.dsp.srth.desktop.uiframework.app.impl.ModularDockingApplicationView.java
/** * Inits the tool windows.//www . j ava 2 s .com */ private synchronized void initToolWindows() { toolWindowManager = new MyDoggyToolWindowManager(); toolWindowManager.setName("toolWindowManager"); contentManager = toolWindowManager.getContentManager(); MultiSplitContentManagerUI multiSplitContentManagerUI = new MyDoggyMultiSplitContentManagerUI(); contentManager.setContentManagerUI(multiSplitContentManagerUI); // specify default settings for multiSplitContentManagerUI multiSplitContentManagerUI.setTabPlacement(TabbedContentManagerUI.TabPlacement.TOP); multiSplitContentManagerUI.setShowAlwaysTab(false); multiSplitContentManagerUI.addContentManagerUIListener(new ContentManagerUIListener() { public boolean contentUIRemoving(ContentManagerUIEvent event) { return JOptionPane.showConfirmDialog(getActiveFrame(), "Are you sure?") == JOptionPane.OK_OPTION; } public void contentUIDetached(ContentManagerUIEvent event) { } }); }
From source file:utils.ZTransform.java
@Override public void actionPerformed(ActionEvent e) { List<CMatrix> loadedCMatrices = CoolMapMaster.getLoadedCMatrices(); if (loadedCMatrices == null || loadedCMatrices.isEmpty()) { Messenger.showWarningMessage("No datasets were imported.", "No data"); return;// ww w . ja v a2 s . c om } SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JTable table = new JTable(); DefaultTableModel defaultTableModel = Utils.getDefaultTableModel(); table.setModel(defaultTableModel); table.getColumnModel().removeColumn(table.getColumnModel().getColumn(0)); table.getTableHeader().setReorderingAllowed(false); int returnVal = JOptionPane.showConfirmDialog(CoolMapMaster.getCMainFrame(), new JScrollPane(table), "Select data", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (returnVal == JOptionPane.OK_OPTION) { int[] selectedRows = table.getSelectedRows(); ArrayList<CMatrix> selectedMatrices = new ArrayList<CMatrix>(); for (int row : selectedRows) { int index = table.convertRowIndexToModel(row); try { String ID = table.getModel().getValueAt(index, 0).toString(); CMatrix mx = CoolMapMaster.getCMatrixByID(ID); if (mx != null) { selectedMatrices.add(mx); } } catch (Exception e) { } } //do createZTransform(selectedMatrices); } } }); }
From source file:utybo.branchingstorytree.swing.OpenBSTGUI.java
private JMenu createShortMenu() { JMenu shortMenu = new JMenu(); addDarkModeCallback(b -> {//from w w w . j a v a 2 s. c om shortMenu.setBackground(b ? OPENBST_BLUE.darker().darker() : OPENBST_BLUE.brighter()); shortMenu.setForeground(b ? Color.WHITE : OPENBST_BLUE); }); shortMenu.setBackground(OPENBST_BLUE.brighter()); shortMenu.setForeground(OPENBST_BLUE); shortMenu.setText(Lang.get("banner.title")); shortMenu.setIcon(new ImageIcon(Icons.getImage("Logo", 16))); JMenuItem label = new JMenuItem(Lang.get("menu.title")); label.setEnabled(false); shortMenu.add(label); shortMenu.addSeparator(); shortMenu.add( new JMenuItem(new AbstractAction(Lang.get("menu.open"), new ImageIcon(Icons.getImage("Open", 16))) { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { openStory(VisualsUtils.askForFile(OpenBSTGUI.this, Lang.get("file.title"))); } })); shortMenu.addSeparator(); shortMenu.add(new JMenuItem( new AbstractAction(Lang.get("menu.create"), new ImageIcon(Icons.getImage("Add Property", 16))) { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { doNewEditor(); } })); JMenu additionalMenu = new JMenu(Lang.get("menu.advanced")); shortMenu.add(additionalMenu); additionalMenu.add(new JMenuItem( new AbstractAction(Lang.get("menu.package"), new ImageIcon(Icons.getImage("Open Archive", 16))) { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { new PackageDialog(instance).setVisible(true); } })); additionalMenu.add(new JMenuItem( new AbstractAction(Lang.get("langcheck"), new ImageIcon(Icons.getImage("LangCheck", 16))) { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { final Map<String, String> languages = new Gson() .fromJson(new InputStreamReader( OpenBST.class.getResourceAsStream( "/utybo/branchingstorytree/swing/lang/langs.json"), StandardCharsets.UTF_8), new TypeToken<Map<String, String>>() { }.getType()); languages.remove("en"); languages.remove("default"); JComboBox<String> jcb = new JComboBox<>(new Vector<>(languages.keySet())); JPanel panel = new JPanel(); panel.add(new JLabel(Lang.get("langcheck.choose"))); panel.add(jcb); int result = JOptionPane.showOptionDialog(OpenBSTGUI.this, panel, Lang.get("langcheck"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); if (result == JOptionPane.OK_OPTION) { Locale selected = new Locale((String) jcb.getSelectedItem()); if (!Lang.getMap().keySet().contains(selected)) { try { Lang.loadTranslationsFromFile(selected, OpenBST.class .getResourceAsStream("/utybo/branchingstorytree/swing/lang/" + languages.get(jcb.getSelectedItem().toString()))); } catch (UnrespectedModelException | IOException e1) { LOG.warn("Failed to load translation file", e1); } } ArrayList<String> list = new ArrayList<>(); Lang.getLocaleMap(Locale.ENGLISH).forEach((k, v) -> { if (!Lang.getLocaleMap(selected).containsKey(k)) { list.add(k + "\n"); } }); StringBuilder sb = new StringBuilder(); Collections.sort(list); list.forEach(s -> sb.append(s)); JDialog dialog = new JDialog(OpenBSTGUI.this, Lang.get("langcheck")); dialog.getContentPane().setLayout(new MigLayout()); dialog.getContentPane().add(new JLabel(Lang.get("langcheck.result")), "pushx, growx, wrap"); JTextArea area = new JTextArea(); area.setLineWrap(true); area.setWrapStyleWord(true); area.setText(sb.toString()); area.setEditable(false); area.setBorder(BorderFactory.createLoweredBevelBorder()); JScrollPane jsp = new JScrollPane(area); jsp.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); dialog.getContentPane().add(jsp, "pushx, pushy, growx, growy"); dialog.setSize((int) (Icons.getScale() * 300), (int) (Icons.getScale() * 300)); dialog.setLocationRelativeTo(OpenBSTGUI.this); dialog.setModalityType(ModalityType.APPLICATION_MODAL); dialog.setVisible(true); } } })); additionalMenu.add(new JMenuItem( new AbstractAction(Lang.get("menu.debug"), new ImageIcon(Icons.getImage("Code", 16))) { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { DebugInfo.launch(OpenBSTGUI.this); } })); JMenu includedFiles = new JMenu("Included BST files"); for (Entry<String, String> entry : OpenBST.getInternalFiles().entrySet()) { JMenuItem jmi = new JMenuItem(entry.getKey()); jmi.addActionListener(ev -> { String path = "/bst/" + entry.getValue(); InputStream is = OpenBSTGUI.class.getResourceAsStream(path); ProgressMonitorInputStream pmis = new ProgressMonitorInputStream(OpenBSTGUI.this, "Extracting...", is); new Thread(() -> { try { File f = File.createTempFile("openbstinternal", ".bsp"); FileOutputStream fos = new FileOutputStream(f); IOUtils.copy(pmis, fos); openStory(f); } catch (final IOException e) { LOG.error("IOException caught", e); showException(Lang.get("file.error").replace("$e", e.getClass().getSimpleName()) .replace("$m", e.getMessage()), e); } }).start(); }); includedFiles.add(jmi); } additionalMenu.add(includedFiles); shortMenu.addSeparator(); JMenu themesMenu = new JMenu(Lang.get("menu.themes")); shortMenu.add(themesMenu); themesMenu.setIcon(new ImageIcon(Icons.getImage("Color Wheel", 16))); ButtonGroup themesGroup = new ButtonGroup(); JRadioButtonMenuItem jrbmi; jrbmi = new JRadioButtonMenuItem(Lang.get("menu.themes.dark")); if (0 == selectedTheme) { jrbmi.setSelected(true); } jrbmi.addActionListener(e -> switchLaF(0, DARK_THEME)); themesMenu.add(jrbmi); themesGroup.add(jrbmi); jrbmi = new JRadioButtonMenuItem(Lang.get("menu.themes.light")); if (1 == selectedTheme) { jrbmi.setSelected(true); } jrbmi.addActionListener(e -> switchLaF(1, LIGHT_THEME)); themesMenu.add(jrbmi); themesGroup.add(jrbmi); jrbmi = new JRadioButtonMenuItem(Lang.get("menu.themes.debug")); if (2 == selectedTheme) { jrbmi.setSelected(true); } jrbmi.addActionListener(e -> switchLaF(2, DEBUG_THEME)); themesMenu.add(jrbmi); themesGroup.add(jrbmi); JMenu additionalLightThemesMenu = new JMenu(Lang.get("menu.themes.morelight")); int j = 3; for (Map.Entry<String, LookAndFeel> entry : ADDITIONAL_LIGHT_THEMES.entrySet()) { int jf = j; jrbmi = new JRadioButtonMenuItem(entry.getKey()); if (j == selectedTheme) jrbmi.setSelected(true); jrbmi.addActionListener(e -> switchLaF(jf, entry.getValue())); additionalLightThemesMenu.add(jrbmi); themesGroup.add(jrbmi); j++; } themesMenu.add(additionalLightThemesMenu); JMenu additionalDarkThemesMenu = new JMenu(Lang.get("menu.themes.moredark")); for (Map.Entry<String, LookAndFeel> entry : ADDITIONAL_DARK_THEMES.entrySet()) { int jf = j; jrbmi = new JRadioButtonMenuItem(entry.getKey()); if (j == selectedTheme) jrbmi.setSelected(true); jrbmi.addActionListener(e -> switchLaF(jf, entry.getValue())); additionalDarkThemesMenu.add(jrbmi); themesGroup.add(jrbmi); j++; } themesMenu.add(additionalDarkThemesMenu); shortMenu.add(new JMenuItem( new AbstractAction(Lang.get("menu.about"), new ImageIcon(Icons.getImage("About", 16))) { /** * */ private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { new AboutDialog(instance).setVisible(true); } })); return shortMenu; }
From source file:view.CertificateManagementDialog.java
private String getUserInputPassword() { JPanel panel = new JPanel(); JLabel lblInsertPassword = new JLabel(Bundle.getBundle().getString("insertKeystorePassword")); JPasswordField pf = new JPasswordField(10); panel.add(lblInsertPassword);//from w ww . j a v a 2 s.c o m panel.add(pf); String[] options = new String[] { Bundle.getBundle().getString("btn.ok"), Bundle.getBundle().getString("btn.cancel") }; int option = JOptionPane.showOptionDialog(null, panel, null, JOptionPane.NO_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[1]); if (option == JOptionPane.OK_OPTION) { char[] password = pf.getPassword(); return new String(password); } return null; }
From source file:view.ManageOrganization.java
private void active_deactive_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_active_deactive_buttonActionPerformed // TODO add your handling code here: int showConfirmDialog = JOptionPane.showConfirmDialog(rootPane, "Are you sure ?"); if (showConfirmDialog == JOptionPane.OK_OPTION) { String id = jTable1.getValueAt(jTable1.getSelectedRow(), 0).toString(); String status = jTable1.getValueAt(jTable1.getSelectedRow(), 2).toString(); System.out.println(status); Dbcon dbcon = new Dbcon(); int nextStatusCode = 0; if (status.toLowerCase().trim().equals("active")) { nextStatusCode = 0;/* w w w . j a v a 2s . co m*/ jTable1.setValueAt("blocked", jTable1.getSelectedRow(), 2); active_deactive_button.setText("RECOVER"); } else { nextStatusCode = 1; jTable1.setValueAt("active", jTable1.getSelectedRow(), 2); active_deactive_button.setText("DELETE"); } dbcon.update("update tbl_organisation set org_status=" + nextStatusCode + " where organisation_id='" + id + "'"); } }
From source file:vnreal.gui.control.MyEditingPopupGraphMousePlugin.java
@Override protected void createEdgeMenuEntries(final Point point, final N graph, final LayerViewer<V, E> vv, List<E> links) {/*from w w w . j a v a 2 s . c o m*/ JMenuItem mi; if (links.size() == 1) { final E link = links.get(0); final int layer = vv.getLayer().getLayer(); // create the add/edit/remove resource/demand menu items createAddConstraintMenuItem(link, layer); createEditConstraintMenuItem(link, layer); createRemoveConstraintMenuItem(link, layer); popup.addSeparator(); // deleting the selected link mi = new JMenuItem("Delete link"); mi.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(GUI.getInstance(), "Delete link \"" + link.toString() + "\"?", "Delete link", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { @SuppressWarnings("rawtypes") Network net = ToolKit.getScenario().getNetworkStack().getLayer(layer); if ((net instanceof SubstrateNetwork && ((SubstrateNetwork) net).removeEdge((SubstrateLink) link)) || (net instanceof VirtualNetwork && ((VirtualNetwork) net).removeEdge((VirtualLink) link))) { vv.updateUI(); } else { throw new AssertionError("Deleting link failed!"); } } } }); popup.add(mi); } }
From source file:vnreal.gui.control.MyEditingPopupGraphMousePlugin.java
@Override protected void createVertexMenuEntries(final Point point, final N graph, final LayerViewer<V, E> vv, final List<V> nodes) { JMenuItem mi;//ww w. j a v a 2 s .c om final int layer = vv.getLayer().getLayer(); if (nodes.size() == 1) { final V node = nodes.get(0); // create the add/edit/remove resource/demand menu items createAddConstraintMenuItem(node, layer); createEditConstraintMenuItem(node, layer); createRemoveConstraintMenuItem(node, layer); popup.addSeparator(); // delete the selected node mi = new JMenuItem("Delete node"); mi.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(GUI.getInstance(), "Delete node \"" + node.toString() + "\"?", "Delete node", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { @SuppressWarnings("rawtypes") Network net = ToolKit.getScenario().getNetworkStack().getLayer(layer); if ((net instanceof SubstrateNetwork && ((SubstrateNetwork) net).removeVertex((SubstrateNode) node)) || (net instanceof VirtualNetwork && ((VirtualNetwork) net).removeVertex((VirtualNode) node))) { vv.updateUI(); } else { throw new AssertionError("Deleting node failed."); } } } }); popup.add(mi); } else if (nodes.size() == 2) { // add a link from v1 to v2 or v2 to v1 if two nodes are selected final V v1 = nodes.get(0); final V v2 = nodes.get(1); // v1 to v2 mi = new JMenuItem("Add link " + v1.toString() + " -> " + v2.toString()); mi.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { addLink(layer, v1, v2); } }); popup.add(mi); // v2 to v1 mi = new JMenuItem("Add link " + v2.toString() + " > " + v1.toString()); mi.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { addLink(layer, v2, v1); } }); popup.add(mi); } }
From source file:wjhk.jupload2.policies.DefaultUploadPolicy.java
/** * If debug is off, the log window may not be visible. We switch the debug * to on, to be sure that some information will be displayed to the user. <BR> * If debug is -1, the log window remains hidden. * //from w ww . ja va 2 s . c o m * @see wjhk.jupload2.policies.UploadPolicy#displayErr(java.lang.String, * java.lang.Exception, int) */ public int displayErr(String errorText, Exception exception, int optionTypes) { // Then, we display it to the user. String alertMsg = errorText; // Then, the message body can be completed by the exception message. if (exception != null && (errorText == null || errorText.equals(""))) { // Ok, we have an exception. if (exception.getCause() != null) { alertMsg = exception.getCause().getMessage(); } else { alertMsg = exception.getMessage(); } } // The message displayed depend on the debug level: if (getDebugLevel() >= 30 && exception != null) { alertMsg = exception.getClass().getName() + ": " + alertMsg; } // Display the message to the user. The kind of alert box depends on the // given options: int buttonClicked = 0; switch (optionTypes) { case -1: // Standard message box. alertStr(alertMsg); buttonClicked = JOptionPane.OK_OPTION; break; case JOptionPane.OK_CANCEL_OPTION: case JOptionPane.YES_NO_CANCEL_OPTION: case JOptionPane.YES_NO_OPTION: buttonClicked = confirmDialogStr(alertMsg, optionTypes); break; default: // This is a problem. Let's display it to the user as a standard // alert box. alertStr(alertMsg); buttonClicked = JOptionPane.OK_OPTION; // Then, we log this new problem. String msg = "Unknown optionType in displayErr(String, Exception, int)"; alertStr(msg); logErr(msg, null); } // First, we log the error. logErr(errorText, exception); return buttonClicked; }
From source file:xmlconverter.tools.ErrorHandling.java
/** * Handles an exception. This method will copy log file to whatever user * specifies./* w ww . j a v a 2 s . c o m*/ * * @param message * @param th */ public void errorHandling(String message, Throwable th) { if (mainFrame == null) { int opt = JOptionPane.showConfirmDialog(mainFrame.getFrame(), "This option is now allowed\n", "Nope. Use different constructor", JOptionPane.OK_OPTION); } else { String fs = File.separator; saveFile = new SaveFile(mainFrame); log.fatal(message, th); int opt = JOptionPane.showConfirmDialog(mainFrame.getFrame(), "Please save this file and mail it to developer for a review.\n" + "See debug console!\n" + "File will be saved in the selected directorie\n" + "Do you want to save this file?", "Save debug.log to", JOptionPane.YES_NO_OPTION); if (opt == JOptionPane.OK_OPTION) { try { File destLogDir = saveFile.saveFile(); File srcFile = new File(System.getProperty("java.io.tmpdir") + fs + "debug.log"); FileUtils.copyFileToDirectory(srcFile, destLogDir); } catch (IOException | NullPointerException | SecurityException e) { log.error("Could not copy log file!", e); } log.info("Log file was successfully saved!"); } } }
From source file:xtrememp.update.SoftwareUpdate.java
public static void checkForUpdates(final boolean showDialogs) { checkForUpdatesWorker = new SwingWorker<Version, Void>() { @Override//from w w w. j ava 2 s . c om protected Version doInBackground() throws Exception { logger.debug("checkForUpdates: started..."); long startTime = System.currentTimeMillis(); Version version = getLastVersion(new URL(updatesURL)); if (showDialogs) { // Simulate (if needed) a delay of 2 sec max to let the user cancel the task. long delayTime = System.currentTimeMillis() - startTime - 2000; if (delayTime > 0) { Thread.sleep(delayTime); } } return version; } @Override protected void done() { logger.debug("checkForUpdates: done"); if (checkForUpdatesDialog != null && checkForUpdatesDialog.isVisible()) { checkForUpdatesDialog.dispose(); } if (!isCancelled()) { try { newerVersion = get(); if (newerVersion != null && newerVersion.compareTo(currentVersion) == 1) { logger.debug("checkForUpdates: currentVersion = {}", currentVersion); logger.debug("checkForUpdates: newerVersion = {}", newerVersion); logger.debug("SoftwareUpdate::checkForUpdates: updates found"); Object[] options = { tr("Button.Cancel") }; Desktop desktop = null; if (Desktop.isDesktopSupported()) { desktop = Desktop.getDesktop(); if (desktop.isSupported(Desktop.Action.BROWSE)) { options = new Object[] { tr("Button.Download"), tr("Button.Cancel") }; } } JPanel panel = new JPanel(new BorderLayout(0, 10)); panel.add(new JLabel("<html>" + tr("Dialog.SoftwareUpdate.UpdatesFound") + " (" + newerVersion + ")</html>"), BorderLayout.CENTER); JCheckBox hideCheckBox = null; if (Settings.isAutomaticUpdatesEnabled()) { hideCheckBox = new JCheckBox( tr("Dialog.SoftwareUpdate.DisableAutomaticCheckForUpdates")); panel.add(hideCheckBox, BorderLayout.SOUTH); } int option = JOptionPane.showOptionDialog(XtremeMP.getInstance().getMainFrame(), panel, tr("Dialog.SoftwareUpdate"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (hideCheckBox != null) { Settings.setAutomaticUpdatesEnabled(!hideCheckBox.isSelected()); } if ((options.length == 2) && (option == JOptionPane.OK_OPTION)) { try { URL url = new URL(newerVersion.getDownloadURL()); desktop.browse(url.toURI()); } catch (Exception ex) { logger.error(ex.getMessage(), ex); } } } else { logger.debug("checkForUpdates: no updates found"); if (showDialogs) { JOptionPane.showMessageDialog(XtremeMP.getInstance().getMainFrame(), tr("Dialog.SoftwareUpdate.NoUpdatesFound"), tr("Dialog.SoftwareUpdate"), JOptionPane.INFORMATION_MESSAGE); } } } catch (Exception ex) { logger.error(ex.getMessage(), ex); if (showDialogs) { JOptionPane.showMessageDialog(XtremeMP.getInstance().getMainFrame(), tr("Dialog.SoftwareUpdate.ConnectionFailure"), tr("Dialog.SoftwareUpdate"), JOptionPane.INFORMATION_MESSAGE); } } } } }; checkForUpdatesWorker.execute(); }