List of usage examples for javax.swing JOptionPane showConfirmDialog
public static int showConfirmDialog(Component parentComponent, Object message, String title, int optionType, int messageType) throws HeadlessException
optionType
parameter, where the messageType
parameter determines the icon to display. From source file:com.a544jh.kanamemory.ui.ProfileChooserPanel.java
private void deleteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteButtonActionPerformed if (JOptionPane.showConfirmDialog(this, "Are you sure?", "Delete Profile", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { JsonFileWriter.deleteProfile((String) profilesList.getSelectedValue(), "profiles"); populateList();/*from w w w. jav a 2 s . c om*/ } }
From source file:org.jfree.chart.demo.JFreeChartDemo.java
/** * Exits the application, but only if the user agrees. */// w ww. java 2 s. c om private void attemptExit() { final String title = this.resources.getString("dialog.exit.title"); final String message = this.resources.getString("dialog.exit.message"); final int result = JOptionPane.showConfirmDialog(this, message, title, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (result == JOptionPane.YES_OPTION) { dispose(); System.exit(0); } }
From source file:com.adito.upgrade.GUIUpgrader.java
public void upgrade() throws Exception { if (JOptionPane.showConfirmDialog(this, "All selected resources will be now upgrade from the source installation to the target. Are you sure you wish to continue?", "Run Upgrade", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) { ///*from w ww .ja v a2s . com*/ final List l = new ArrayList(); for (int i = 0; i < upgradeSelectionPanel.getComponentCount(); i++) { JCheckBox b = (JCheckBox) upgradeSelectionPanel.getComponent(i); if (b.isSelected()) { l.add(b.getClientProperty("upgrade")); } } removeUpgradeSelectionComponent(); invalidate(); removeAll(); // Progress panel JPanel progressPanel = new JPanel(new BorderLayout()); progressPanel.setBorder(BorderFactory.createTitledBorder("Progress")); final JProgressBar b = new JProgressBar(0, l.size()); b.setStringPainted(true); progressPanel.add(b, BorderLayout.CENTER); add(progressPanel, BorderLayout.NORTH); // Console panel JPanel consolePanel = new JPanel(new BorderLayout()); consolePanel.setBorder(BorderFactory.createTitledBorder("Output")); console = new JTextPane(); JScrollPane scrollPane = new JScrollPane(console); consolePanel.add(scrollPane, BorderLayout.CENTER); add(consolePanel, BorderLayout.CENTER); // validate(); repaint(); // Thread t = new Thread() { public void run() { try { for (Iterator i = l.iterator(); i.hasNext();) { AbstractDatabaseUpgrade upgrade = (AbstractDatabaseUpgrade) i.next(); b.setValue(b.getValue() + 1); upgrade.upgrade(GUIUpgrader.this); try { Thread.sleep(750); } catch (InterruptedException ie) { } } info("Complete"); Toolkit.getDefaultToolkit().beep(); } catch (Exception e) { error("Failed to upgrade.", e); } } }; t.start(); } }
From source file:gdt.jgui.entity.webset.JWeblinksPanel.java
/** * Get the context menu.//from w ww . j a v a 2 s.co m * @return the context menu. */ @Override public JMenu getContextMenu() { menu = super.getContextMenu(); int cnt = menu.getItemCount(); mia = new JMenuItem[cnt]; for (int i = 0; i < cnt; i++) mia[i] = menu.getItem(i); menu.addMenuListener(new MenuListener() { @Override public void menuSelected(MenuEvent e) { //System.out.println("WeblinkPanel:getConextMenu:menu selected"); menu.removeAll(); if (mia != null) { for (JMenuItem mi : mia) menu.add(mi); menu.addSeparator(); } if (hasSelectedItems()) { JMenuItem deleteItem = new JMenuItem("Delete"); 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) { String[] sa = JWeblinksPanel.this.listSelectedItems(); if (sa == null) return; String webLinkKey$; Entigrator entigrator = console.getEntigrator(entihome$); Sack entity = entigrator.getEntityAtKey(entityKey$); for (String aSa : sa) { webLinkKey$ = Locator.getProperty(aSa, WEB_LINK_KEY); if (webLinkKey$ == null) continue; entity.removeElementItem("web", webLinkKey$); entity.removeElementItem("web.login", webLinkKey$); entity.removeElementItem("web.icon", webLinkKey$); } entigrator.save(entity); JConsoleHandler.execute(console, locator$); } } }); menu.add(deleteItem); JMenuItem copyItem = new JMenuItem("Copy"); copyItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JItemPanel[] ipa = JWeblinksPanel.this.getItems(); ArrayList<String> sl = new ArrayList<String>(); for (JItemPanel ip : ipa) if (ip.isChecked()) sl.add(ip.getLocator()); String[] sa = sl.toArray(new String[0]); console.clipboard.clear(); for (String aSa : sa) console.clipboard.putString(aSa); } }); menu.add(copyItem); } JMenuItem newItem = new JMenuItem("New"); newItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.out.println("WeblinksPanel:new:" + locator$); Entigrator entigrator = console.getEntigrator(entihome$); Sack entity = entigrator.getEntityAtKey(entityKey$); if (!entity.existsElement("web")) entity.createElement("web"); String webLinkKey$ = Identity.key(); entity.putElementItem("web", new Core("Google", webLinkKey$, "http://www.google.com")); if (!entity.existsElement("web.icon")) entity.createElement("web.icon"); String icon$ = Support.readHandlerIcon(null, JEntitiesPanel.class, "globe.png"); entity.putElementItem("web.icon", new Core(null, webLinkKey$, icon$)); entigrator.save(entity); JWeblinkEditor wle = new JWeblinkEditor(); String wleLocator$ = wle.getLocator(); wleLocator$ = Locator.append(wleLocator$, Entigrator.ENTIHOME, entihome$); wleLocator$ = Locator.append(wleLocator$, EntityHandler.ENTITY_KEY, entityKey$); wleLocator$ = Locator.append(wleLocator$, WEB_LINK_KEY, webLinkKey$); String requesterResponseLocator$ = Locator.compressText(getLocator()); wleLocator$ = Locator.append(wleLocator$, JRequester.REQUESTER_RESPONSE_LOCATOR, requesterResponseLocator$); JConsoleHandler.execute(console, wleLocator$); } }); menu.add(newItem); if (hasItemsToPaste()) { JMenuItem pasteItem = new JMenuItem("Paste"); pasteItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String[] sa = getItemsToPaste(); Entigrator entigrator = console.getEntigrator(entihome$); Sack entity = entigrator.getEntityAtKey(entityKey$); if (!entity.existsElement("web")) entity.createElement("web"); if (!entity.existsElement("web.icon")) entity.createElement("web.icon"); if (!entity.existsElement("web.login")) entity.createElement("web.login"); Properties itemLocator; String webLinkKey$; String webLinkUrl$; String webLinkName$; String webLinkIcon$; String webLinkLogin$; String webLinkPassword$; for (String aSa : sa) { itemLocator = Locator.toProperties(aSa); webLinkKey$ = itemLocator.getProperty(WEB_LINK_KEY); webLinkUrl$ = itemLocator.getProperty(WEB_LINK_URL); webLinkName$ = itemLocator.getProperty(WEB_LINK_NAME); webLinkIcon$ = itemLocator.getProperty(Locator.LOCATOR_ICON); webLinkLogin$ = itemLocator.getProperty(WEB_LINK_LOGIN); webLinkPassword$ = itemLocator.getProperty(WEB_LINK_PASSWORD); if (webLinkKey$ == null || webLinkUrl$ == null) continue; entity.putElementItem("web", new Core(webLinkName$, webLinkKey$, webLinkUrl$)); if (webLinkLogin$ != null || webLinkPassword$ != null) entity.putElementItem("web.login", new Core(webLinkLogin$, webLinkKey$, webLinkPassword$)); if (webLinkIcon$ != null) entity.putElementItem("web.icon", new Core(null, webLinkKey$, webLinkIcon$)); } entigrator.save(entity); JConsoleHandler.execute(console, getLocator()); } }); menu.add(pasteItem); } menu.addSeparator(); JMenuItem doneItem = new JMenuItem("Done"); doneItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (requesterResponseLocator$ != null) { try { byte[] ba = Base64.decodeBase64(requesterResponseLocator$); String responseLocator$ = new String(ba, "UTF-8"); JConsoleHandler.execute(console, responseLocator$); } catch (Exception ee) { Logger.getLogger(JWeblinksPanel.class.getName()).severe(ee.toString()); } } else console.back(); } }); menu.add(doneItem); } @Override public void menuDeselected(MenuEvent e) { } @Override public void menuCanceled(MenuEvent e) { } }); return menu; }
From source file:de.whiledo.iliasdownloader2.swing.service.MainController.java
private void handleFirstStart() { if (!ServiceFunctions.getPropertiesFile().exists()) { JOptionPane.showMessageDialog(mainFrame, "Willkommen bei " + APP_NAME, "Willkommen", JOptionPane.INFORMATION_MESSAGE); JPanel panel = new JPanel(new BorderLayout()); panel.add(new JLabel("<html>Wenn Sie " + APP_NAME + " nutzen mchten, mssen Sie die folgende Punkte akzeptieren." + "<ul>" + "<li>This software is under the GNU GENERAL PUBLIC LICENSE Version 3.<br>" + "View https://github.com/kekru/ILIASDownloader2/blob/master/LICENSE for detailed information." + "</li>" + "<li>Dieses Programm wird Ihr Passwort nicht speichern</li>" + "<li>Dieses Programm wird Ihren Loginnamen und Ihr Passwort nur an den von Ihnen angegebenen Server senden</li>" + "<li>Ihr Passwort wird im Arbeitsspeicher dieses Computers <b>nicht</b> verschlsselt gespeichert.<br>Ein Schadprogramm knnte den Arbeitsspeicher auslesen und so an Ihre Logindaten gelangen.<br>Der Autor von " + APP_NAME + " bernimmt keine Verantwortung fr die Sicherheit Ihrer Logindaten</li>" + "<li>Im nchsten Schritt mssen Sie Ihren Ilias Server eingeben. Bitte achten Sie darauf, dass die Adresse mit 'https://' beginnt.<br>Das bewirkt eine gesicherte Verbindung zwischen " + APP_NAME + " und Ihrem Ilias Server</li>" + "<li>Die Nutzung und die Weitergabe von " + APP_NAME + " ist kostenlos.</li>" + "<li>Beim Programmstart wird auf Updates berprft. Dabei wird lediglich der Programmname an den Updateserver gesendet. Ihre Logindaten oder andere persnliche Daten werden nicht bertragen.<br>Wenn Sie die Updatefunktion ausschalten mchten, starten Sie das Programm mit dem Parameter '" + StartGui.NO_UPDATER + "'</li>" + "</ul>" + "</html>"), BorderLayout.NORTH); JButton licenseButton = new JButton("Open GNU GENERAL PUBLIC LICENSE Version 3"); licenseButton.addActionListener(new ActionListener() { @Override// w w w. jav a2 s .c o m public void actionPerformed(ActionEvent e) { openWebsiteLicense(); } }); panel.add(licenseButton, BorderLayout.CENTER); JCheckBox checkboxAccept = new JCheckBox( "Ich akzeptiere die hier aufgefhrten Bedingungen/I accept these agreements."); checkboxAccept.setSelected(false); panel.add(checkboxAccept, BorderLayout.SOUTH); if (JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog(mainFrame, panel, "Bedingungen", JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE) && checkboxAccept.isSelected()) { chooseServer(); } else { System.exit(0); } } }
From source file:com.microsoftopentechnologies.intellij.helpers.AndroidStudioHelper.java
public static void deleteActivityTemplates(Object caller) throws IOException, InterruptedException { String[] cmd = null;// www. j a v a 2 s . c o m String templatePath = URLDecoder .decode(ApplicationComponent.class.getResource("").getPath().replace("file:/", ""), "UTF-8"); templatePath = templatePath.replace("/", File.separator); templatePath = templatePath.substring(0, templatePath.indexOf(File.separator + "lib")); templatePath = templatePath + File.separator + "plugins" + File.separator + "android" + File.separator; templatePath = templatePath + "lib" + File.separator + "templates" + File.separator + "activities" + File.separator; String[] env = null; String tmpdir = getTempLocation(); BufferedInputStream bufferedInputStream = new BufferedInputStream( ServiceCodeReferenceHelper.getTemplateResource("ActivityTemplate.zip")); unZip(bufferedInputStream, tmpdir); if (System.getProperty("os.name").toLowerCase().startsWith("windows")) { try { VirtualFile mobileTemplate = LocalFileSystem.getInstance() .findFileByIoFile(new File(templatePath + mobileServicesTemplateName)); VirtualFile officeTemplate = LocalFileSystem.getInstance() .findFileByIoFile(new File(templatePath + officeTemplateName)); if (mobileTemplate != null) mobileTemplate.delete(caller); if (officeTemplate != null) officeTemplate.delete(caller); } catch (IOException ex) { PrintWriter printWriter = new PrintWriter(tmpdir + "\\script.bat"); printWriter.println("@echo off"); printWriter.println("del \"" + templatePath + mobileServicesTemplateName + "\" /Q /S"); printWriter.println("del \"" + templatePath + officeTemplateName + "\" /Q /S"); printWriter.flush(); printWriter.close(); String[] tmpcmd = { tmpdir + "\\elevate.exe", "script.bat", "1" }; cmd = tmpcmd; ArrayList<String> tempenvlist = new ArrayList<String>(); for (String envval : System.getenv().keySet()) tempenvlist.add(String.format("%s=%s", envval, System.getenv().get(envval))); tempenvlist.add("PRECOMPILE_STREAMLINE_FILES=1"); env = new String[tempenvlist.size()]; tempenvlist.toArray(env); Runtime rt = Runtime.getRuntime(); Process proc = rt.exec(cmd, env, new File(tmpdir)); proc.waitFor(); } } else if (System.getProperty("os.name").toLowerCase().startsWith("mac")) { VirtualFile mobileTemplate = LocalFileSystem.getInstance() .findFileByIoFile(new File(templatePath + mobileServicesTemplateName)); VirtualFile officeTemplate = LocalFileSystem.getInstance() .findFileByIoFile(new File(templatePath + officeTemplateName)); if (mobileTemplate != null && officeTemplate != null) { exec(new String[] { "osascript", "-e", "do shell script \"rm -r \\\"/" + templatePath + mobileServicesTemplateName + "\\\"\"", "-e", "do shell script \"rm -r \\\"/" + templatePath + officeTemplateName + "\\\"\"" }, tmpdir); } } else { try { VirtualFile mobileTemplate = LocalFileSystem.getInstance() .findFileByIoFile(new File(templatePath + mobileServicesTemplateName)); VirtualFile officeTemplate = LocalFileSystem.getInstance() .findFileByIoFile(new File(templatePath + officeTemplateName)); mobileTemplate.delete(caller); officeTemplate.delete(caller); } catch (IOException ex) { JPasswordField pf = new JPasswordField(); int okCxl = JOptionPane.showConfirmDialog(null, pf, "To copy Microsoft Services templates, the plugin needs your password:", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (okCxl == JOptionPane.OK_OPTION) { String password = new String(pf.getPassword()); exec(new String[] { "echo", password, "|", "sudo", "-S", "rm", "-r", tmpdir + mobileServicesTemplateName, templatePath + mobileServicesTemplateName }, tmpdir); exec(new String[] { "echo", password, "|", "sudo", "-S", "rm", "-r", tmpdir + officeTemplateName, templatePath + officeTemplateName }, tmpdir); } } } }
From source file:unikn.dbis.univis.visualization.graph.plaf.VGraphUI.java
public VGraphUI() { VHintButton zoomIn = new VHintButton(VIcons.ZOOM_IN); menu.add(zoomIn);/*w w w . java 2s.c o m*/ zoomIn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VGraphCell cell = selectedCell; Object o = cell.getUserObject(); if (o != null && o instanceof VChartPanel) { VChartPanel chart = (VChartPanel) o; chart.zoomInBoth(0, 0); graph.repaint(); } } }); VHintButton zoomOut = new VHintButton(VIcons.ZOOM_OUT); menu.add(zoomOut); zoomOut.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VGraphCell cell = selectedCell; Object o = cell.getUserObject(); if (o != null && o instanceof VChartPanel) { VChartPanel chart = (VChartPanel) o; chart.zoomOutBoth(0, 0); graph.repaint(); } } }); VHintButton settings = new VHintButton(VIcons.APPLICATION_FORM_EDIT); menu.add(settings); settings.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VGraphCell cell = selectedCell; Object o = cell.getUserObject(); if (o != null && o instanceof VChartPanel) { VChartPanel chart = (VChartPanel) o; ChartEditor editor = ChartEditorManager.getChartEditor(chart.getChart()); int result = JOptionPane.showConfirmDialog(graph.getParent(), editor, "Chart_Properties", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (result == JOptionPane.OK_OPTION) { editor.updateChart(chart.getChart()); graph.repaint(); } } } }); VHintButton legend = new VHintButton(VIcons.BRICKS); menu.add(legend); legend.addActionListener(new ActionListener() { /** * Invoked when an action occurs. */ public void actionPerformed(ActionEvent e) { VGraphCell cell = selectedCell; Object o = cell.getUserObject(); if (o != null && o instanceof VChartPanel) { VChartPanel chart = (VChartPanel) o; VLegend legend = new VLegend(chart.getChart()); JPopupMenu menu = new JPopupMenu(); menu.add(legend); menu.show(graph, 0, 0); } } }); }
From source file:gdt.jgui.tool.JEntityEditor.java
/** * Get the context menu./*from www .j ava 2s . co m*/ * @return the context menu. */ @Override public JMenu getContextMenu() { menu = new JMenu("Context"); menu.addMenuListener(new MenuListener() { @Override public void menuSelected(MenuEvent e) { // System.out.println("EntityEditor:getConextMenu:menu selected"); if (editCellItem != null) menu.remove(editCellItem); if (deleteItemsItem != null) menu.remove(deleteItemsItem); if (copyItem != null) menu.remove(copyItem); if (pasteItem != null) menu.remove(pasteItem); if (cutItem != null) menu.remove(cutItem); if (hasEditingCell()) { //menu.addSeparator(); editCellItem = new JMenuItem("Edit item"); editCellItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String locator$ = getEditCellLocator(); if (locator$ != null) JConsoleHandler.execute(console, locator$); } }); menu.add(editCellItem); } if (hasSelectedRows()) { deleteItemsItem = new JMenuItem("Delete items"); deleteItemsItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int response = JOptionPane.showConfirmDialog(JEntityEditor.this, "Delete selected items ?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) { deleteRows(); } } }); menu.add(deleteItemsItem); copyItem = new JMenuItem("Copy"); copyItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { element$ = null; content = getContent(true); } }); menu.add(copyItem); cutItem = new JMenuItem("Cut"); cutItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int i = tabbedPane.getSelectedIndex(); element$ = tabbedPane.getTitleAt(i); content = getContent(true); } }); menu.add(cutItem); } if (content != null) { pasteItem = new JMenuItem("Paste"); pasteItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { pasteTable(content); int j = tabbedPane.getSelectedIndex(); if (element$ != null) { int cnt = tabbedPane.getComponentCount(); for (int i = 0; i < cnt; i++) { if (element$.equals(tabbedPane.getTitleAt(i))) { tabbedPane.setSelectedIndex(i); cutTable(content); tabbedPane.setSelectedIndex(j); } } } } }); menu.add(pasteItem); } } @Override public void menuDeselected(MenuEvent e) { } @Override public void menuCanceled(MenuEvent e) { } }); JMenuItem doneItem = new JMenuItem("Done"); doneItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { save(); console.back(); } }); menu.add(doneItem); JMenuItem cancelItem = new JMenuItem("Cancel"); cancelItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { console.back(); } }); menu.add(cancelItem); menu.addSeparator(); JMenuItem addItemItem = new JMenuItem("Add item"); addItemItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { addRow(); } }); menu.add(addItemItem); JMenuItem addElementItem = new JMenuItem("Add element"); addElementItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String element$ = "new element"; //addElement(element$); String locator$ = getRenameElementLocator(element$); JConsoleHandler.execute(console, locator$); } }); menu.add(addElementItem); JMenuItem deleteElementItem = new JMenuItem("Delete element"); deleteElementItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int response = JOptionPane.showConfirmDialog(JEntityEditor.this, "Delete element ?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) { tabbedPane.remove(tabbedPane.getSelectedComponent()); } } }); menu.add(deleteElementItem); JMenuItem renameElementItem = new JMenuItem("Rename element"); renameElementItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int i = tabbedPane.getSelectedIndex(); String locator$ = getRenameElementLocator(tabbedPane.getTitleAt(i)); JConsoleHandler.execute(console, locator$); } }); menu.add(renameElementItem); menu.addSeparator(); if (hasEditingCell()) { editCellItem = new JMenuItem("Edit item"); editCellItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String locator$ = getEditCellLocator(); if (locator$ != null) JConsoleHandler.execute(console, locator$); } }); menu.add(editCellItem); } return menu; }
From source file:gdt.jgui.entity.bonddetail.JBondDetailPanel.java
/** * Get the context menu./* ww w .j a v a 2 s.c om*/ * @return the context menu. */ @Override public JMenu getContextMenu() { menu1 = new JMenu("Context"); menu1.addMenuListener(new MenuListener() { @Override public void menuSelected(MenuEvent e) { // System.out.println("JBondDetailPanel:getConextMenu:BEGIN"); menu1.removeAll(); JMenuItem selectItem = new JMenuItem("Select all"); selectItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JItemPanel[] ipa = getItems(); if (ipa != null) { for (JItemPanel ip : ipa) ip.setChecked(true); } } }); menu1.add(selectItem); JMenuItem unselectItem = new JMenuItem("Unselect all"); unselectItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JItemPanel[] ipa = getItems(); if (ipa != null) { for (JItemPanel ip : ipa) ip.setChecked(false); } } }); menu1.addSeparator(); JMenuItem doneItem = new JMenuItem("Done"); doneItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (requesterResponseLocator$ != null) { try { byte[] ba = Base64.decodeBase64(requesterResponseLocator$); String responseLocator$ = new String(ba, "UTF-8"); JConsoleHandler.execute(console, responseLocator$); } catch (Exception ee) { LOGGER.severe(ee.toString()); } } else console.back(); } }); menu1.add(doneItem); menu1.addSeparator(); addItem = new JMenuItem("Add"); addItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Entigrator entigrator = console.getEntigrator(entihome$); JContext adp = (JContext) ExtensionHandler.loadHandlerInstance(entigrator, BondDetailHandler.EXTENSION_KEY, "gdt.jgui.entity.bonddetail.JAddDetailPanel"); String adpLocator$ = adp.getLocator(); adpLocator$ = Locator.append(adpLocator$, Entigrator.ENTIHOME, entihome$); adpLocator$ = Locator.append(adpLocator$, EntityHandler.ENTITY_KEY, entityKey$); JConsoleHandler.execute(console, adpLocator$); } catch (Exception ee) { LOGGER.severe(ee.toString()); } } }); menu1.add(addItem); if (hasToPaste()) { JMenuItem pasteItem = new JMenuItem("Paste"); pasteItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { paste(); } }); menu1.add(pasteItem); } if (hasSelectedItems()) { JMenuItem deleteItem = new JMenuItem("Delete"); 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) { delete(); JBondDetailPanel bdp = new JBondDetailPanel(); String bdpLocator$ = bdp.getLocator(); bdpLocator$ = Locator.append(bdpLocator$, Entigrator.ENTIHOME, entihome$); bdpLocator$ = Locator.append(bdpLocator$, EntityHandler.ENTITY_KEY, entityKey$); bdpLocator$ = Locator.append(bdpLocator$, JBondsPanel.BOND_KEY, bondKey$); JConsoleHandler.execute(console, bdpLocator$); } } }); menu1.add(deleteItem); } } @Override public void menuDeselected(MenuEvent e) { } @Override public void menuCanceled(MenuEvent e) { } }); return menu1; }
From source file:org.jfree.chart.demo.SuperDemo.java
private void attemptExit() { String s = "Confirm"; String s1 = "Are you sure you want to exit the demo?"; int i = JOptionPane.showConfirmDialog(this, s1, s, 0, 3); if (i == 0) { dispose();//w w w.j a v a2 s . co m System.exit(0); } }