List of usage examples for javax.swing JOptionPane YES_NO_OPTION
int YES_NO_OPTION
To view the source code for javax.swing JOptionPane YES_NO_OPTION.
Click Source Link
showConfirmDialog
. From source file:gdt.jgui.entity.JEntityStructurePanel.java
/** * The default constructor.//from ww w . j a v a 2 s. co m */ public JEntityStructurePanel() { setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); scrollPane = new JScrollPane(); add(scrollPane); popup = new JPopupMenu(); popup.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { popup.removeAll(); JMenuItem facetsItem = new JMenuItem("Facets"); popup.add(facetsItem); facetsItem.setHorizontalTextPosition(JMenuItem.RIGHT); facetsItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // System.out.println("EntityStructurePanel:renderer:component locator$="+nodeLocator$); JEntityFacetPanel efp = new JEntityFacetPanel(); String efpLocator$ = efp.getLocator(); Properties locator = Locator.toProperties(selection$); String entihome$ = locator.getProperty(Entigrator.ENTIHOME); String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); efpLocator$ = Locator.append(efpLocator$, Entigrator.ENTIHOME, entihome$); efpLocator$ = Locator.append(efpLocator$, EntityHandler.ENTITY_KEY, entityKey$); JConsoleHandler.execute(console, efpLocator$); } }); JMenuItem copyItem = new JMenuItem("Copy"); popup.add(copyItem); copyItem.setHorizontalTextPosition(JMenuItem.RIGHT); copyItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { console.clipboard.clear(); String locator$ = (String) node.getUserObject(); if (locator$ != null) console.clipboard.putString(locator$); } }); if (!isFirst) { popup.addSeparator(); JMenuItem excludeItem = new JMenuItem("Exclude"); popup.add(excludeItem); excludeItem.setHorizontalTextPosition(JMenuItem.RIGHT); excludeItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int response = JOptionPane.showConfirmDialog(console.getContentPanel(), "Exclude ?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) { try { Properties locator = Locator.toProperties(selection$); String entihome$ = locator.getProperty(Entigrator.ENTIHOME); String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); Entigrator entigrator = console.getEntigrator(entihome$); Sack component = entigrator.getEntityAtKey(entityKey$); String[] sa = entigrator.ent_listContainers(component); if (sa != null) { Sack container; for (String aSa : sa) { container = entigrator.getEntityAtKey(aSa); if (container != null) entigrator.col_breakRelation(container, component); } } JConsoleHandler.execute(console, JEntityStructurePanel.this.locator$); } catch (Exception ee) { Logger.getLogger(JEntityStructurePanel.class.getName()).info(ee.toString()); } } } }); JMenuItem deleteItem = new JMenuItem("Delete"); popup.add(deleteItem); deleteItem.setHorizontalTextPosition(JMenuItem.RIGHT); deleteItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int response = JOptionPane.showConfirmDialog(console.getContentPanel(), "Delete ?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) { try { Properties locator = Locator.toProperties(selection$); String entihome$ = locator.getProperty(Entigrator.ENTIHOME); String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); Entigrator entigrator = console.getEntigrator(entihome$); Sack component = entigrator.getEntityAtKey(entityKey$); entigrator.deleteEntity(component); JConsoleHandler.execute(console, JEntityStructurePanel.this.locator$); } catch (Exception ee) { Logger.getLogger(JEntityStructurePanel.class.getName()).info(ee.toString()); } } } }); } if (hasToInclude()) { popup.addSeparator(); JMenuItem includeItem = new JMenuItem("Include"); popup.add(includeItem); includeItem.setHorizontalTextPosition(JMenuItem.RIGHT); includeItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { include(); JConsoleHandler.execute(console, JEntityStructurePanel.this.locator$); } }); } } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { } @Override public void popupMenuCanceled(PopupMenuEvent e) { // TODO Auto-generated method stub } }); }
From source file:com.frostwire.gui.updates.UpdateMediator.java
public void showUpdateMessage() { if (latestMsg == null) { return;//from w w w. ja va 2 s .c om } int result = JOptionPane.showConfirmDialog(null, latestMsg.getMessageInstallerReady(), I18n.tr("Update"), JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE); if (result == JOptionPane.YES_OPTION) { startUpdate(); } }
From source file:com.frostwire.gui.updates.InstallerUpdater.java
private void showUpdateMessage() { GUIMediator.safeInvokeLater(new Runnable() { public void run() { if (_executableFile == null) { return; }//w w w . j a v a 2s.c om int result = JOptionPane.showConfirmDialog(null, _updateMessage.getMessageInstallerReady(), I18n.tr("Update"), JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE); if (result == JOptionPane.YES_OPTION) { try { if (OSUtils.isWindows()) { String[] commands = new String[] { "CMD.EXE", "/C", _executableFile.getAbsolutePath() }; ProcessBuilder pbuilder = new ProcessBuilder(commands); pbuilder.start(); } else if (OSUtils.isLinux() && OSUtils.isUbuntu()) { String[] commands = new String[] { "gdebi-gtk", _executableFile.getAbsolutePath() }; ProcessBuilder pbuilder = new ProcessBuilder(commands); pbuilder.start(); } else if (OSUtils.isMacOSX()) { String[] mountCommand = new String[] { "hdiutil", "attach", _executableFile.getAbsolutePath() }; String[] finderShowCommand = new String[] { "open", "/Volumes/" + FilenameUtils.getBaseName(_executableFile.getName()) }; ProcessBuilder pbuilder = new ProcessBuilder(mountCommand); Process mountingProcess = pbuilder.start(); mountingProcess.waitFor(); pbuilder = new ProcessBuilder(finderShowCommand); pbuilder.start(); } GUIMediator.shutdown(); } catch (Throwable e) { LOG.error("Unable to launch new installer", e); } } } }); }
From source file:com.edduarte.protbox.core.registry.PbxFile.java
public void setBackupPolicy(BackupPolicy backupPolicy) { if (!backupPolicy.equals(BackupPolicy.Ask)) { boolean changeBackupPolicy = true; if (snapshotStack.size() > backupPolicy.maxBackupSize) { changeBackupPolicy = JOptionPane.showConfirmDialog(null, "The number of stored backup copies have been reduced to " + backupPolicy.maxBackupSize + ", and prior backups above that number will be deleted.\n" + "Are you sure you want to change the backup policy?", "Confirm backup policy change", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_NO_OPTION; }/* www . j ava2 s . c o m*/ if (changeBackupPolicy) { this.backupPolicy = backupPolicy; while (snapshotStack.size() > backupPolicy.maxBackupSize) { snapshotStack.removeLast(); } } } else { this.backupPolicy = backupPolicy; } }
From source file:canreg.client.gui.management.CanReg4MigrationInternalFrame.java
@Action public void cancelAction() throws RemoteException, IOException { isPaused = true;//from w w w. j a v a 2 s . c om if (cTask != null) { if (JOptionPane.showInternalConfirmDialog( CanRegClientApp.getApplication().getMainFrame().getContentPane(), java.util.ResourceBundle.getBundle("canreg/client/gui/dataentry/resources/ImportView") .getString("REALLY_CANCEL?"), java.util.ResourceBundle.getBundle("canreg/client/gui/dataentry/resources/ImportView") .getString("PLEASE_CONFIRM."), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { cTask.cancel(true); JOptionPane.showInternalMessageDialog( CanRegClientApp.getApplication().getMainFrame().getContentPane(), java.util.ResourceBundle.getBundle("canreg/client/gui/dataentry/resources/ImportView") .getString("IMPORT_OF_FILE_INTERUPTED"), java.util.ResourceBundle.getBundle("canreg/client/gui/dataentry/resources/ImportView") .getString("WARNING"), JOptionPane.WARNING_MESSAGE); cTask = null; this.dispose(); } else { isPaused = false; } } else { this.dispose(); } }
From source file:gdt.jgui.entity.procedure.JProcedurePanel.java
/** * Get the context menu./*from ww w .j av a 2 s .co m*/ * @return the context menu. */ @Override public JMenu getContextMenu() { menu = new JMenu("Context"); menu.addMenuListener(new MenuListener() { @Override public void menuSelected(MenuEvent e) { menu.removeAll(); JMenuItem runItem = new JMenuItem("Run"); runItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { run(); } }); menu.add(runItem); Entigrator entigrator = console.getEntigrator(entihome$); Sack procedure = entigrator.getEntityAtKey(entityKey$); if (procedure.getElementItem("parameter", "noreset") == null) { JMenuItem resetItem = new JMenuItem("Reset"); resetItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int response = JOptionPane.showConfirmDialog(console.getContentPanel(), "Reset source to default ?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) reset(); } }); menu.add(resetItem); } JMenuItem folderItem = new JMenuItem("Open folder"); folderItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { File file = new File(entihome$ + "/" + entityKey$); Desktop.getDesktop().open(file); } catch (Exception ee) { Logger.getLogger(getClass().getName()).info(ee.toString()); } } }); menu.add(folderItem); try { //Entigrator entigrator=console.getEntigrator(entihome$); Sack entity = entigrator.getEntityAtKey(entityKey$); String template$ = entity.getAttributeAt("template"); if (template$ != null) { JMenuItem adaptClone = new JMenuItem("Adapt clone"); adaptClone.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { adaptClone(console, getLocator()); } catch (Exception ee) { Logger.getLogger(getClass().getName()).info(ee.toString()); } } }); menu.add(adaptClone); } } catch (Exception ee) { Logger.getLogger(getClass().getName()).info(ee.toString()); } } @Override public void menuDeselected(MenuEvent e) { } @Override public void menuCanceled(MenuEvent e) { } }); return menu; }
From source file:org.cytoscape.dyn.internal.graphMetrics.GraphMetricsResultsPanel.java
/** * //from ww w . ja va2s . co m */ public void saveData() { JFileChooser saveFileDialog = new JFileChooser(); int save = saveFileDialog.showSaveDialog(null); if (save == JFileChooser.APPROVE_OPTION) { FileWriter writer = null; try { File file = saveFileDialog.getSelectedFile(); if (file.exists()) { if (JOptionPane.showConfirmDialog(null, "The specified file already exists. Do you want to overwrite it?", "Warning - File Exists", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { writer = new FileWriter(file); for (int i = 0; i < this.dataset.getSeriesCount(); i++) { writer.write(this.dataset.getSeries(i).getKey().toString() + "\n"); for (int j = 0; j < this.dataset.getSeries(i).getItemCount(); j++) { writer.write(this.dataset.getSeries(i).getDataItem(j).toString() + "\n"); } } } } else { writer = new FileWriter(file); for (int i = 0; i < this.dataset.getSeriesCount(); i++) { writer.write(this.dataset.getSeries(i).getKey().toString() + "\n"); for (int j = 0; j < this.dataset.getSeries(i).getItemCount(); j++) { writer.write(this.dataset.getSeries(i).getDataItem(j).toString() + "\n"); } } } } catch (Exception e) { e.printStackTrace(); } try { writer.flush(); writer.close(); } catch (Exception e) { e.printStackTrace(); } } }
From source file:edu.ku.brc.specify.tools.FormDisplayer.java
/** * /* w w w . ja v a2 s. c om*/ */ public void generateFormImages() { if (setup()) { createFormImagesIndexFile(); } int userChoice = JOptionPane.showConfirmDialog(getTopWindow(), getResourceString("FormDisplayer.CHOOSE_VIEWLIST"), //$NON-NLS-1$ getResourceString("FormDisplayer.CHOOSE_VIEWLIST_TITLE"), //$NON-NLS-1$ JOptionPane.YES_NO_OPTION); doAll = userChoice == JOptionPane.YES_OPTION ? true : false; if (setup()) { SpecifyAppContextMgr appContext = (SpecifyAppContextMgr) AppContextMgr.getInstance(); viewList = doAll ? appContext.getEntirelyAllViews() : appContext.getAllViews(); SwingUtilities.invokeLater(new Runnable() { /* (non-Javadoc) * @see java.lang.Runnable#run() */ public void run() { showView(); } }); } JButton stopBtn = UIHelper.createButton("Stop Generating Images"); PanelBuilder pb = new PanelBuilder(new FormLayout("p", "p")); pb.add(stopBtn, (new CellConstraints()).xy(1, 1)); pb.setDefaultDialogBorder(); cancelDlg = new CustomDialog((Frame) null, "Stop Image Generation", false, CustomDialog.OK_BTN, pb.getPanel()); cancelDlg.setOkLabel(getResourceString("CLOSE")); cancelDlg.setAlwaysOnTop(true); cancelDlg.setVisible(true); //Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets(cancelDlg.getGraphicsConfiguration());; Rectangle screenRect = cancelDlg.getGraphicsConfiguration().getBounds(); int y = screenRect.height - (cancelDlg.getSize().height * 2); cancelDlg.setLocation(screenRect.x, y); stopBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { synchronized (okToProc) { okToProc.set(false); viewInx = viewList.size(); } } }); } }); }
From source file:com.sshtools.appframework.ui.SshToolsApplicationFrame.java
/** * @param application/*w w w . j ava 2s . c om*/ * @param panel * * @throws SshToolsApplicationException */ public void init(final SshToolsApplication application, SshToolsApplicationPanel panel) throws SshToolsApplicationException { log.debug("Initialising frame"); this.panel = panel; this.application = application; if (application != null) { setTitle(application.getApplicationName() + " - " + application.getApplicationVersion()); } setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); // Register the File menu panel.registerActionMenu(new ActionMenu("File", "File", 'f', 0)); // Register the Exit action if (showExitAction && application != null) { panel.registerAction(exitAction = new ExitAction(application, this)); // Register the New Window Action } if (showNewWindowAction && application != null) { panel.registerAction(newWindowAction = new NewWindowAction(application)); // Register the Help menu } panel.registerActionMenu(new ActionMenu("Help", "Help", 'h', 99)); // Register the About box action if (showAboutBox && application != null) { panel.registerAction(aboutAction = new AboutAction(this, application)); } getApplicationPanel().rebuildActionComponents(); // JPanel p = new JPanel(new ToolBarLayout()); JPanel p = new JPanel(new BorderLayout(0, 0)); JPanel center = new JPanel(new BorderLayout(0, 0)); if (panel.getJMenuBar() != null) { setJMenuBar(panel.getJMenuBar()); } if (panel.getToolBar() != null) { // center.add(toolSeparator = new JSeparator(JSeparator.HORIZONTAL), // BorderLayout.NORTH); // toolSeparator.setVisible(panel.getToolBar().isVisible()); // panel.getToolBar().addComponentListener(new ComponentAdapter() { // public void componentShown(ComponentEvent e) { // toolSeparator.setVisible(SshToolsApplicationFrame.this.panel.getToolBar().isVisible()); // } // // public void componentHidden(ComponentEvent e) { // toolSeparator.setVisible(SshToolsApplicationFrame.this.panel.getToolBar().isVisible()); // } // // }); final SshToolsApplicationPanel pnl = panel; panel.getToolBar().addComponentListener(new ComponentAdapter() { public void componentHidden(ComponentEvent evt) { // toolSeparator.setVisible(pnl.getToolBar().isVisible()); } }); p.add(panel.getToolBar(), BorderLayout.NORTH); } center.add(panel, BorderLayout.CENTER); p.add(center, BorderLayout.CENTER); getContentPane().setLayout(new GridLayout(1, 1, 0, 0)); getContentPane().add(p); // Watch for the frame closing setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { if (application != null) { application.closeContainer(SshToolsApplicationFrame.this); } else { int confirm = JOptionPane.showOptionDialog(SshToolsApplicationFrame.this, "Close " + getTitle() + "?", "Close Operation", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); if (confirm == 0) { hide(); } } } }); // If this is the first frame, center the window on the screen Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); boolean found = false; if (application != null && application.getContainerCount() != 0) { for (int i = 0; (i < application.getContainerCount()) && !found; i++) { SshToolsApplicationContainer c = application.getContainerAt(i); if (c instanceof SshToolsApplicationFrame) { SshToolsApplicationFrame f = (SshToolsApplicationFrame) c; setSize(f.getSize()); Point newLocation = new Point(f.getX(), f.getY()); newLocation.x += 48; newLocation.y += 48; if (newLocation.x > (screenSize.getWidth() - 64)) { newLocation.x = 0; } if (newLocation.y > (screenSize.getHeight() - 64)) { newLocation.y = 0; } setLocation(newLocation); found = true; } } } if (!found) { // Is there a previous stored geometry we can use? if (PreferencesStore.preferenceExists(PREF_LAST_FRAME_GEOMETRY)) { setBounds(PreferencesStore.getRectangle(PREF_LAST_FRAME_GEOMETRY, getBounds())); } else { pack(); setSize(800, 600); UIUtil.positionComponent(SwingConstants.CENTER, this); } } log.debug("Initialisation of frame complete"); }
From source file:com.mindcognition.mindraider.ui.swing.trash.TrashJPanel.java
/** * Constructor./*from w w w .j av a2 s.c o m*/ */ private TrashJPanel() { treeNodeToResourceUriMap = new HashMap(); rootNode = new DefaultMutableTreeNode(Messages.getString("TrashJPanel.notebookArchive")); treeModel = new DefaultTreeModel(rootNode); treeModel.addTreeModelListener(new MyTreeModelListener()); tree = new JTree(treeModel); tree.setEditable(false); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); tree.addTreeExpansionListener(this); tree.addTreeWillExpandListener(this); tree.setShowsRootHandles(true); tree.putClientProperty("JTree.lineStyle", "Angled"); // tree rendered // TODO implement own renderer in order to tooltips tree.setCellRenderer(new TrashTreeCellRenderer(IconsRegistry.getImageIcon("trashFull.png"), IconsRegistry.getImageIcon("explorerNotebookIcon.png"))); setLayout(new BorderLayout()); // control panel JToolBar tp = new JToolBar(); tp.setLayout(new GridLayout(1, 6)); undoButton = new JButton("", IconsRegistry.getImageIcon("trashUndo.png")); undoButton.setEnabled(false); undoButton.setToolTipText("Restore Outline"); undoButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); if (node == null) { return; } new RestoreNotebookJDialog((String) treeNodeToResourceUriMap.get(node), "Restore Outline", "Restore", true); } }); tp.add(undoButton); deleteButton = new JButton("", IconsRegistry.getImageIcon("explorerDeleteSmall.png")); deleteButton.setToolTipText("Delete Outline"); deleteButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); if (node == null) { return; } int result = JOptionPane.showConfirmDialog(MindRaider.mainJFrame, "Do you really want to DELETE this Outline?", "Delete Outline", JOptionPane.YES_NO_OPTION); if (result == JOptionPane.YES_OPTION) { MindRaider.labelCustodian.deleteOutline((String) treeNodeToResourceUriMap.get(node)); refresh(); ExplorerJPanel.getInstance().refresh(); } } }); tp.add(deleteButton); emptyButton = new JButton("", IconsRegistry.getImageIcon("trashEmpty.png")); emptyButton.setToolTipText(Messages.getString("TrashJPanel.emptyArchive")); emptyButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int result = JOptionPane.showConfirmDialog(MindRaider.mainJFrame, "Do you really want to DELETE all discarded Outlines?", "Empty Trash", JOptionPane.YES_NO_OPTION); if (result == JOptionPane.YES_OPTION) { final SwingWorker worker = new SwingWorker() { public Object construct() { ProgressDialogJFrame progressDialogJFrame = new ProgressDialogJFrame("Empty Trash", "<html><br> <b>Deleting:</b> </html>"); try { ResourceDescriptor[] resourceDescriptors = MindRaider.labelCustodian .getDiscardedOutlineDescriptors(); if (resourceDescriptors != null) { for (int i = 0; i < resourceDescriptors.length; i++) { MindRaider.labelCustodian.deleteOutline(resourceDescriptors[i].getUri()); } refresh(); } } finally { if (progressDialogJFrame != null) { progressDialogJFrame.dispose(); } } return null; } }; worker.start(); } } }); tp.add(emptyButton); add(tp, BorderLayout.NORTH); // add the tree JScrollPane scrollPane = new JScrollPane(tree); add(scrollPane); // build the whole tree buildTree(); // click handler tree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); if (node == null) { return; } logger.debug("Tree selection path: " + node.getPath()[node.getLevel()]); enableDisableToolbarButtons(node.getLevel()); } }); }