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:de.fhg.igd.mapviewer.server.file.FileTiler.java
/** * Load the command paths from the preferences or ask the user for them *//*from ww w. j a v a2 s . c o m*/ private void loadCommandPaths() { String convert = pref.get(PREF_CONVERT, null); String identify = pref.get(PREF_IDENTIFY, null); JFileChooser commandChooser = new JFileChooser(); if (convert != null && identify != null) { if (JOptionPane.showConfirmDialog(null, "<html>Found paths to executables:<br/><b>" + convert + "<br/>" + identify + "</b><br/>Do you want to use this settings?</html>", "Paths to executables", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.NO_OPTION) { convert = null; identify = null; } } if (convert == null) { // ask for convert path convert = askForPath(commandChooser, new ContainsFileFilter("convert"), "Please select your convert executable"); } if (convert != null && identify == null) { // ask for identify path identify = askForPath(commandChooser, new ContainsFileFilter("identify"), "Please select your identify executable"); } if (convert == null) pref.remove(PREF_CONVERT); else pref.put(PREF_CONVERT, convert); if (identify == null) pref.remove(PREF_IDENTIFY); else pref.put(PREF_IDENTIFY, identify); convertPath = convert; identifyPath = identify; }
From source file:edu.ku.brc.af.ui.db.JEditComboBox.java
/** * It may or may not ask if it can add, and then it adds the new item * @param strArg the string that is to be added * @return whether it was added//w ww.java 2 s . com */ protected boolean askToAdd(String strArg) { if (ignoreFocus) { return false; } if (isNotEmpty(strArg)) { ignoreFocus = true; String msg = UIRegistry.getLocalizedMessage("JEditComboBox.ADD_NEW_VALUE", strArg); //$NON-NLS-1$ String title = UIRegistry.getResourceString("JEditComboBox.ADD_NEW_ITEM_TITLE"); //$NON-NLS-1$ if (!askBeforeSave || JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(this, msg, title, JOptionPane.YES_NO_OPTION)) { PickListItemIFace pli = null; if (dbAdapter != null) { if (!dbAdapter.isReadOnly()) { pli = dbAdapter.addItem(strArg, strArg); } } else { pli = new PickListItem(strArg, strArg, new Timestamp(System.currentTimeMillis())); // this is ok because the items will not be saved. } if (pli != null) { this.addItem(pli); this.setSelectedItem(pli); } ignoreFocus = false; return true; } ignoreFocus = false; } return false; }
From source file:edu.scripps.fl.pubchem.xmltool.gui.PubChemXMLCreatorGUI.java
public void actionPerformed(ActionEvent e) { try {// w w w.jav a 2 s . c om setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); if (e.getSource() == jbnFileTemplate) { gc.fileChooser(jtfFileTemplate, ".xml", "open"); jtfFileTemplate.setEnabled(true); } else if (e.getSource() == jbnFileExcel) { gc.fileChooser(jtfFileExcel, ".xlsx", "open"); } else if (e.getSource() == jbnRunCreator) { String stringTemplate = jtfFileTemplate.getText(); InputStream fileTemplate; if (stringTemplate.equals(template) | stringTemplate.equals("")) { URL url = getClass().getClassLoader().getResource("blank.xml"); fileTemplate = url.openStream(); } else fileTemplate = new FileInputStream(jtfFileTemplate.getText()); File fileExcel = new File(jtfFileExcel.getText()); File fileOutput = File.createTempFile("pubchem", ".xml"); fileOutput.deleteOnExit(); PubChemAssay assay = new PubChemXMLCreatorController().createPubChemXML(fileTemplate, fileExcel, fileOutput); String message = assay.getMessage(); if (!message.equals("")) { int nn = JOptionPane.showOptionDialog(this, notError + message + "\nWould you like to edit your Excel Workbook?", SwingGUI.APP_NAME, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); if (nn == JOptionPane.YES_OPTION) { log.info("Opening Excel Workbook with Desktop: " + fileExcel); Desktop.getDesktop().open(fileExcel); } else { log.info("Opening XML file: " + fileOutput); Desktop.getDesktop().open(fileOutput); } } else { log.info("Opening XML file: " + fileOutput); Desktop.getDesktop().open(fileOutput); } } else if (e.getSource() == jbnReportCreator) { File fileExcel = new File(jtfFileExcel.getText()); File filePDFOutput = File.createTempFile("PubChem_PDF_Report", ".pdf"); File fileWordOutput = File.createTempFile("PubChem_Word_Report", ".docx"); filePDFOutput.deleteOnExit(); fileWordOutput.deleteOnExit(); ArrayList<PubChemAssay> assay = new ReportController().createReport(pcDep, fileExcel, filePDFOutput, fileWordOutput, isInternal); String message = null; for (PubChemAssay xx : assay) { message = xx.getMessage(); if (!message.equals("")) { int nn = JOptionPane.showOptionDialog(this, notError + message + "\nWould you like to edit your Excel Workbook?", SwingGUI.APP_NAME, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); if (nn == JOptionPane.YES_OPTION) { log.info("Opening Excel Workbook with Desktop: " + fileExcel); Desktop.getDesktop().open(fileExcel); } else { gc.openPDF(isInternal, filePDFOutput, this); Desktop.getDesktop().open(fileWordOutput); } } else { gc.openPDF(isInternal, filePDFOutput, this); Desktop.getDesktop().open(fileWordOutput); } } } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } catch (Throwable throwable) { SwingGUI.handleError(this, throwable); } }
From source file:com.emental.mindraider.ui.outline.OutlineArchiveJPanel.java
public void actionPerformed(ActionEvent e) { int result = JOptionPane.showConfirmDialog(MindRaider.mainJFrame, "Do you really want to restore this Note?", "Restore Note", JOptionPane.YES_NO_OPTION); if (result == JOptionPane.YES_OPTION) { // determine selected concept parameters int selectedRow = table.getSelectedRow(); if (selectedRow >= 0) { // map the row to the model (column sorters may change it) selectedRow = table.convertRowIndexToModel(selectedRow); if (tableModel.getDiscardedConcepts() != null && tableModel.getDiscardedConcepts().length > selectedRow) { try { MindRaider.noteCustodian.undiscard(MindRaider.profile.getActiveOutlineUri().toString(), tableModel.getDiscardedConcepts()[selectedRow].getUri()); } catch (Exception e1) { logger.debug("Unable to restore the note!", e1); // {{debug}} }//from w w w . j a va2 s .c o m OutlineJPanel.getInstance().refresh(); } return; } } }
From source file:edu.scripps.fl.pubchem.xmltool.gui.PubChemXMLExtractorGUI.java
private URL templateForExcel() { URL template;//from www .jav a2s. c om int nn = JOptionPane.showOptionDialog(this, "If you are editing the Excel file, would you like a BAO categorized comments sheet included?", SwingGUI.APP_NAME, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); String resource = "ExcelTemplate"; if (nn == JOptionPane.YES_OPTION) resource = resource + "_withBAO_EditingVersion"; if (isInternal) resource = resource + "_Internal"; log.info("Getting resource: " + resource); template = getClass().getClassLoader().getResource(resource + ".xlsx"); return template; }
From source file:com.vsquaresystem.safedeals.readyreckoner.ReadyReckonerService.java
public Boolean checkExistingDataa() throws IOException { logger.info("check ke andar hai bhai??"); Vector checkCellVectorHolder = read(); logger.info("checkCellVectorHolder line116 :{}", checkCellVectorHolder); logger.info("read in check line117 :{}", read()); int excelSize = checkCellVectorHolder.size() - 1; System.out.println("excelSize" + excelSize); List<Readyreckoner> rs = readyReckonerDAL.getAll(); JFrame parent = new JFrame(); System.out.println("rs" + rs); int listSize = rs.size(); logger.info("rsss:::::", listSize); System.out.println("rsss:::::" + listSize); if (excelSize == listSize || excelSize > listSize) { JDialog.setDefaultLookAndFeelDecorated(true); int response = JOptionPane.showConfirmDialog(null, "Do you want to continue?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); switch (response) { case JOptionPane.NO_OPTION: System.out.println("No button clicked"); JOptionPane.showMessageDialog(parent, "upload Cancelled"); break; case JOptionPane.YES_NO_OPTION: saveToDatabase(checkCellVectorHolder); System.out.println("Yes button clicked"); JOptionPane.showMessageDialog(parent, "Saved succesfully"); break; case JOptionPane.CLOSED_OPTION: System.out.println("JOptionPane closed"); break; }//from www . j a v a2 s. c om } else { System.out.println("No selected"); } return true; }
From source file:com.sshtools.common.ui.SshToolsApplicationInternalFrame.java
/** * * * @param application//from w w w .java 2 s. c o m * @param panel * * @throws SshToolsApplicationException */ public void init(final SshToolsApplication application, SshToolsApplicationPanel panel) throws SshToolsApplicationException { this.panel = panel; this.application = application; if (application != null) { setTitle(ConfigurationLoader.getVersionString(application.getApplicationName(), application.getApplicationVersion())); // + " " + application.getApplicationVersion()); } // Register the File menu panel.registerActionMenu(new SshToolsApplicationPanel.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 SshToolsApplicationPanel.ActionMenu("Help", "Help", 'h', 99)); // Register the About box action if (showAboutBox && application != null) { panel.registerAction(aboutAction = new AboutAction(this, application)); } // Register the Changelog box action if (showChangelogBox && application != null) { panel.registerAction(changelogAction = new ChangelogAction(this, application)); } panel.registerAction(faqAction = new FAQAction()); panel.registerAction(beginnerAction = new BeginnerAction()); panel.registerAction(advancedAction = new AdvancedAction()); getApplicationPanel().rebuildActionComponents(); JPanel p = new JPanel(new BorderLayout()); if (panel.getJMenuBar() != null) { setJMenuBar(panel.getJMenuBar()); } if (panel.getToolBar() != null) { JPanel t = new JPanel(new BorderLayout()); t.add(panel.getToolBar(), BorderLayout.NORTH); t.add(toolSeparator = new JSeparator(JSeparator.HORIZONTAL), BorderLayout.SOUTH); toolSeparator.setVisible(panel.getToolBar().isVisible()); final SshToolsApplicationPanel pnl = panel; panel.getToolBar().addComponentListener(new ComponentAdapter() { public void componentHidden(ComponentEvent evt) { log.debug("Tool separator is now " + pnl.getToolBar().isVisible()); toolSeparator.setVisible(pnl.getToolBar().isVisible()); } }); p.add(t, BorderLayout.NORTH); } p.add(panel, BorderLayout.CENTER); if (panel.getStatusBar() != null) { p.add(panel.getStatusBar(), BorderLayout.SOUTH); } getContentPane().setLayout(new GridLayout(1, 1)); getContentPane().add(p); // Watch for the frame closing //setDefaultCloseOperation(JInternalFrame.DO_NOTHING_ON_CLOSE); addVetoableChangeListener(new VetoableChangeListener() { public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException { if (application != null) { application.closeContainer(SshToolsApplicationInternalFrame.this); } else { if (evt.getPropertyName().equals(IS_CLOSED_PROPERTY)) { boolean changed = ((Boolean) evt.getNewValue()).booleanValue(); if (changed) { int confirm = JOptionPane.showOptionDialog(SshToolsApplicationInternalFrame.this, "Close " + getTitle() + "?", "Close Operation", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); if (confirm == 0) { SshToolsApplicationInternalFrame.this.getDesktopPane() .remove(SshToolsApplicationInternalFrame.this); } } } } } }); /*this.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { if(application!=null) application.closeContainer(SshToolsApplicationFrame.this); else 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(); UIUtil.positionComponent(SwingConstants.CENTER, this); } }*/ pack(); }
From source file:DialogDemo.java
/** Creates the panel shown by the first tab. */ private JPanel createSimpleDialogBox() { final int numButtons = 4; JRadioButton[] radioButtons = new JRadioButton[numButtons]; final ButtonGroup group = new ButtonGroup(); JButton showItButton = null;//from www .j a va 2 s . c o m final String defaultMessageCommand = "default"; final String yesNoCommand = "yesno"; final String yeahNahCommand = "yeahnah"; final String yncCommand = "ync"; radioButtons[0] = new JRadioButton("OK (in the L&F's words)"); radioButtons[0].setActionCommand(defaultMessageCommand); radioButtons[1] = new JRadioButton("Yes/No (in the L&F's words)"); radioButtons[1].setActionCommand(yesNoCommand); radioButtons[2] = new JRadioButton("Yes/No " + "(in the programmer's words)"); radioButtons[2].setActionCommand(yeahNahCommand); radioButtons[3] = new JRadioButton("Yes/No/Cancel " + "(in the programmer's words)"); radioButtons[3].setActionCommand(yncCommand); for (int i = 0; i < numButtons; i++) { group.add(radioButtons[i]); } radioButtons[0].setSelected(true); showItButton = new JButton("Show it!"); showItButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String command = group.getSelection().getActionCommand(); // ok dialog if (command == defaultMessageCommand) { JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green."); // yes/no dialog } else if (command == yesNoCommand) { int n = JOptionPane.showConfirmDialog(frame, "Would you like green eggs and ham?", "An Inane Question", JOptionPane.YES_NO_OPTION); if (n == JOptionPane.YES_OPTION) { setLabel("Ewww!"); } else if (n == JOptionPane.NO_OPTION) { setLabel("Me neither!"); } else { setLabel("Come on -- tell me!"); } // yes/no (not in those words) } else if (command == yeahNahCommand) { Object[] options = { "Yes, please", "No way!" }; int n = JOptionPane.showOptionDialog(frame, "Would you like green eggs and ham?", "A Silly Question", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (n == JOptionPane.YES_OPTION) { setLabel("You're kidding!"); } else if (n == JOptionPane.NO_OPTION) { setLabel("I don't like them, either."); } else { setLabel("Come on -- 'fess up!"); } // yes/no/cancel (not in those words) } else if (command == yncCommand) { Object[] options = { "Yes, please", "No, thanks", "No eggs, no ham!" }; int n = JOptionPane.showOptionDialog(frame, "Would you like some green eggs to go " + "with that ham?", "A Silly Question", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[2]); if (n == JOptionPane.YES_OPTION) { setLabel("Here you go: green eggs and ham!"); } else if (n == JOptionPane.NO_OPTION) { setLabel("OK, just the ham, then."); } else if (n == JOptionPane.CANCEL_OPTION) { setLabel("Well, I'm certainly not going to eat them!"); } else { setLabel("Please tell me what you want!"); } } return; } }); return createPane(simpleDialogDesc + ":", radioButtons, showItButton); }
From source file:de.juwimm.cms.gui.admin.PanUnitGroupPerUser.java
public void unload() { if (unitPickData.isModified() || groupPickData.isModified()) { int i = JOptionPane.showConfirmDialog(this, rb.getString("dialog.wantToSave"), "CMS", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (i == JOptionPane.YES_OPTION) { saveChanges(currentSelected); }// w w w .j av a 2 s . c om unitPickData.setModified(false); groupPickData.setModified(false); } }
From source file:uk.co.petertribble.jkstat.gui.KstatBaseChartFrame.java
/** * Saves the current chart as an image in png format. The user can select * the filename, and is asked to confirm the overwrite of an existing file. *//*from w w w .jav a 2s. c o m*/ public void saveImage() { JFileChooser fc = new JFileChooser(); if (fc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) { File f = fc.getSelectedFile(); if (f.exists()) { int ok = JOptionPane.showConfirmDialog(this, KstatResources.getString("SAVEAS.OVERWRITE.TEXT") + " " + f.toString(), KstatResources.getString("SAVEAS.CONFIRM.TEXT"), JOptionPane.YES_NO_OPTION); if (ok != JOptionPane.YES_OPTION) { return; } } BufferedImage bi = kbc.getChart().createBufferedImage(500, 300); try { ImageIO.write(bi, "png", f); /* * According to the API docs this should throw an IOException * on error, but this doesn't seem to be the case. As a result * it's necessary to catch exceptions more generally. Even this * doesn't work properly, but at least we manage to convey the * message to the user that the write failed, even if the * error itself isn't handled. */ } catch (Exception ioe) { JOptionPane.showMessageDialog(this, ioe.toString(), KstatResources.getString("SAVEAS.ERROR.TEXT"), JOptionPane.ERROR_MESSAGE); } } }