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:com.nikonhacker.gui.EmulatorUI.java
private void openDecodeNkldDialog() { JTextField sourceFile = new JTextField(); JTextField destinationFile = new JTextField(); FileSelectionPanel sourceFileSelectionPanel = new FileSelectionPanel("Source file", sourceFile, false); sourceFileSelectionPanel.setFileFilter("nkld*.bin", "Lens correction data file (nkld*.bin)"); final JComponent[] inputs = new JComponent[] { sourceFileSelectionPanel, new FileSelectionPanel("Destination file", destinationFile, true) }; if (JOptionPane.OK_OPTION == JOptionPane.showOptionDialog(this, inputs, "Choose source file and destination dir", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, JOptionPane.DEFAULT_OPTION)) { try {/*from w ww .ja v a 2s .c o m*/ new NkldDecoder().decode(sourceFile.getText(), destinationFile.getText(), false); JOptionPane .showMessageDialog( this, "Decoding complete.\nFile '" + new File(destinationFile.getText()).getAbsolutePath() + "' was created.", "Done", JOptionPane.INFORMATION_MESSAGE); } catch (FirmwareFormatException e) { JOptionPane.showMessageDialog(this, e.getMessage() + "\nPlease see console for full stack trace", "Error decoding files", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } } }
From source file:br.com.atmatech.sac.view.ViewAtendimento.java
private void jBexcluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBexcluirActionPerformed // TODO add your handling code here: if (Integer.valueOf(jTidatendimento.getText()) > 0) { if (JOptionPane.showConfirmDialog(this, "Deseja Excluir o Atendimento", "Atendimento", JOptionPane.OK_CANCEL_OPTION) == 0) { deleteAtendimento();//from www. j a va 2 s.c om } } }
From source file:com.isti.traceview.common.TraceViewChartPanel.java
/** * Displays a dialog that allows the user to edit the properties for the current chart. * /* w w w .ja v a2 s . c om*/ * @since 1.0.3 */ public void doEditChartProperties() { ChartEditor editor = ChartEditorManager.getChartEditor(this.chart); int result = JOptionPane.showConfirmDialog(this, editor, localizationResources.getString("Chart_Properties"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (result == JOptionPane.OK_OPTION) { editor.updateChart(this.chart); } }
From source file:org.rdv.viz.chart.ChartPanel.java
/** * Displays a dialog that allows the user to edit the properties for the * current chart.//from ww w .j a va 2 s . com * * @since 1.0.3 */ public void doEditChartProperties() { ChartEditor editor = ChartEditorManager.getChartEditor(this.chart); int result = JOptionPane.showConfirmDialog(this, editor, localizationResources.getString("Chart_Properties"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (result == JOptionPane.OK_OPTION) { editor.updateChart(this.chart); } }
From source file:com.nikonhacker.gui.EmulatorUI.java
private void openAnalyseDialog(final int chip) { JTextField optionsField = new JTextField(); JTextField destinationField = new JTextField(); // compute and try default names for options file. // In order : <firmware>.dfr.txt , <firmware>.txt , dfr.txt (or the same for dtx) File optionsFile = new File(imageFile[chip].getParentFile(), FilenameUtils.getBaseName(imageFile[chip].getAbsolutePath()) + ((chip == Constants.CHIP_FR) ? ".dfr.txt" : ".dtx.txt")); if (!optionsFile.exists()) { optionsFile = new File(imageFile[chip].getParentFile(), FilenameUtils.getBaseName(imageFile[chip].getAbsolutePath()) + ".txt"); if (!optionsFile.exists()) { optionsFile = new File(imageFile[chip].getParentFile(), ((chip == Constants.CHIP_FR) ? "dfr.txt" : "dtx.txt")); if (!optionsFile.exists()) { optionsFile = null;/* w w w. jav a2 s .com*/ } } } if (optionsFile != null) { optionsField.setText(optionsFile.getAbsolutePath()); } // compute default name for output File outputFile = new File(imageFile[chip].getParentFile(), FilenameUtils.getBaseName(imageFile[chip].getAbsolutePath()) + ".asm"); destinationField.setText(outputFile.getAbsolutePath()); final JCheckBox writeOutputCheckbox = new JCheckBox("Write disassembly to file"); final FileSelectionPanel destinationFileSelectionPanel = new FileSelectionPanel("Destination file", destinationField, false); destinationFileSelectionPanel.setFileFilter(".asm", "Assembly language file (*.asm)"); writeOutputCheckbox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { boolean writeToFile = writeOutputCheckbox.isSelected(); destinationFileSelectionPanel.setEnabled(writeToFile); prefs.setWriteDisassemblyToFile(chip, writeToFile); } }); writeOutputCheckbox.setSelected(prefs.isWriteDisassemblyToFile(chip)); destinationFileSelectionPanel.setEnabled(prefs.isWriteDisassemblyToFile(chip)); FileSelectionPanel fileSelectionPanel = new FileSelectionPanel( (chip == Constants.CHIP_FR) ? "Dfr options file" : "Dtx options file", optionsField, false); fileSelectionPanel.setFileFilter((chip == Constants.CHIP_FR) ? ".dfr.txt" : ".dtx.txt", (chip == Constants.CHIP_FR) ? "Dfr options file (*.dfr.txt)" : "Dtx options file (*.dtx.txt)"); final JComponent[] inputs = new JComponent[] { //new FileSelectionPanel("Source file", sourceFile, false, dependencies), fileSelectionPanel, writeOutputCheckbox, destinationFileSelectionPanel, makeOutputOptionCheckBox(chip, OutputOption.STRUCTURE, prefs.getOutputOptions(chip), true), makeOutputOptionCheckBox(chip, OutputOption.ORDINAL, prefs.getOutputOptions(chip), true), makeOutputOptionCheckBox(chip, OutputOption.PARAMETERS, prefs.getOutputOptions(chip), true), makeOutputOptionCheckBox(chip, OutputOption.INT40, prefs.getOutputOptions(chip), true), makeOutputOptionCheckBox(chip, OutputOption.MEMORY, prefs.getOutputOptions(chip), true), new JLabel("(hover over the options for help. See also 'Tools/Options/Disassembler output')", SwingConstants.CENTER) }; if (JOptionPane.OK_OPTION == JOptionPane.showOptionDialog(this, inputs, "Choose analyse options", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, JOptionPane.DEFAULT_OPTION)) { String outputFilename = writeOutputCheckbox.isSelected() ? destinationField.getText() : null; boolean cancel = false; if (outputFilename != null) { if (new File(outputFilename).exists()) { if (JOptionPane.showConfirmDialog(this, "File '" + outputFilename + "' already exists.\nDo you really want to overwrite it ?", "File exists", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) != JOptionPane.YES_OPTION) { cancel = true; } } } if (!cancel) { AnalyseProgressDialog analyseProgressDialog = new AnalyseProgressDialog(this, framework.getPlatform(chip).getMemory()); analyseProgressDialog.startBackgroundAnalysis(chip, optionsField.getText(), outputFilename); analyseProgressDialog.setVisible(true); } } }
From source file:GUI.MainWindow.java
public void addReference(JTree tree, JList list, Reference current) { DefaultMutableTreeNode node = ((DefaultMutableTreeNode) tree.getLastSelectedPathComponent()); if (node == null) { return;//from w w w . j av a 2s .com } Object obj = node.getUserObject(); if (!(obj instanceof Vulnerability)) { return; // here be monsters, most likely in the merge tree } Vulnerability vuln = (Vulnerability) obj; DefaultListModel dlm = (DefaultListModel) list.getModel(); // Build Input Field and display it JTextField description = new JTextField(); JTextField url = new JTextField(); // If current is not null then pre-set the description and risk if (current != null) { description.setText(current.getDescription()); url.setText(current.getUrl()); } JLabel error = new JLabel( "A valid URL needs to be supplied including the protocol i.e. http://www.github.com"); error.setForeground(Color.red); Object[] message = { "Description:", description, "URL:", url }; String url_string = null; Reference newref = null; while (url_string == null) { int option = JOptionPane.showConfirmDialog(null, message, "Add Reference", JOptionPane.OK_CANCEL_OPTION); if (option == JOptionPane.OK_OPTION) { System.out.println("User clicked ok, validating data"); String ref_desc = description.getText(); String ref_url = url.getText(); if (!ref_desc.equals("") || !ref_url.equals("")) { // Both have values // Try to validate URL try { URL u = new URL(url.getText()); u.toURI(); url_string = url.getText(); // Causes loop to end with a valid url } catch (MalformedURLException ex) { url_string = null; //ex.printStackTrace(); } catch (URISyntaxException ex) { url_string = null; //ex.printStackTrace(); } } } else if (option == JOptionPane.CANCEL_OPTION || option == JOptionPane.CLOSED_OPTION) { System.out.println("User clicked cancel/close"); return; // ends the loop without making any chages } if (url_string == null) { // We need to show an error saying that the url failed to parse Object[] message2 = { error, "Description:", description, "URL:", url }; message = message2; } } // If you get here there is a valid reference URL and description Reference ref = new Reference(description.getText(), url.getText()); if (current == null) { // Add it to the vuln vuln.addReference(ref); // Add it to the GUI dlm.addElement(ref); System.out.println("Valid reference added: " + ref); } else { // Modify it in the vuln vuln.modifyReference(current, ref); // Update the GUI dlm.removeElement(current); dlm.addElement(ref); System.out.println("Valid reference modified: " + ref); } }
From source file:com.rapidminer.gui.plotter.charts.AbstractChartPanel.java
/** * Displays a dialog that allows the user to edit the properties for the current chart. * //from ww w . jav a2s . c om * @since 1.0.3 */ @Override public void doEditChartProperties() { ChartEditor editor = ChartEditorManager.getChartEditor(this.chart); int result = JOptionPane.showConfirmDialog(this, editor, localizationResources.getString("Chart_Properties"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (result == JOptionPane.OK_OPTION) { editor.updateChart(this.chart); } }
From source file:com.nikonhacker.gui.EmulatorUI.java
private void openUIOptionsDialog() { JPanel options = new JPanel(new GridLayout(0, 1)); options.setName("User Interface"); // Button size ActionListener buttonSizeRadioListener = new ActionListener() { @Override//from w w w . jav a 2s . c o m public void actionPerformed(ActionEvent e) { prefs.setButtonSize(e.getActionCommand()); } }; JRadioButton small = new JRadioButton("Small"); small.setActionCommand(BUTTON_SIZE_SMALL); small.addActionListener(buttonSizeRadioListener); if (BUTTON_SIZE_SMALL.equals(prefs.getButtonSize())) small.setSelected(true); JRadioButton medium = new JRadioButton("Medium"); medium.setActionCommand(BUTTON_SIZE_MEDIUM); medium.addActionListener(buttonSizeRadioListener); if (BUTTON_SIZE_MEDIUM.equals(prefs.getButtonSize())) medium.setSelected(true); JRadioButton large = new JRadioButton("Large"); large.setActionCommand(BUTTON_SIZE_LARGE); large.addActionListener(buttonSizeRadioListener); if (BUTTON_SIZE_LARGE.equals(prefs.getButtonSize())) large.setSelected(true); ButtonGroup group = new ButtonGroup(); group.add(small); group.add(medium); group.add(large); // Close windows on stop final JCheckBox closeAllWindowsOnStopCheckBox = new JCheckBox("Close all windows on Stop"); closeAllWindowsOnStopCheckBox.setSelected(prefs.isCloseAllWindowsOnStop()); // Refresh interval JPanel refreshIntervalPanel = new JPanel(); final JTextField refreshIntervalField = new JTextField(5); refreshIntervalPanel.add(new JLabel("Refresh interval for cpu, screen, etc. (ms):")); refreshIntervalField.setText("" + prefs.getRefreshIntervalMs()); refreshIntervalPanel.add(refreshIntervalField); // Setup panel options.add(new JLabel("Button size :")); options.add(small); options.add(medium); options.add(large); options.add(closeAllWindowsOnStopCheckBox); options.add(refreshIntervalPanel); options.add(new JLabel("Larger value greatly increases emulation speed")); if (JOptionPane.OK_OPTION == JOptionPane.showOptionDialog(this, options, "Preferences", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, JOptionPane.DEFAULT_OPTION)) { // save prefs.setButtonSize(group.getSelection().getActionCommand()); prefs.setCloseAllWindowsOnStop(closeAllWindowsOnStopCheckBox.isSelected()); int refreshIntervalMs = 0; try { refreshIntervalMs = Integer.parseInt(refreshIntervalField.getText()); } catch (NumberFormatException e) { // noop } refreshIntervalMs = Math.max(Math.min(refreshIntervalMs, 10000), 10); prefs.setRefreshIntervalMs(refreshIntervalMs); applyPrefsToUI(); } }
From source file:fi.hoski.remote.ui.Admin.java
private void swapPatrolShift(AnyDataObject user) { Long memberNumber = (Long) user.get(Member.JASENNO); PatrolShift selectedShift = choosePatrolShift(user); if (selectedShift != null) { SwapRequest req = new SwapRequest(); req.set(Repository.JASENNO, user.createKey()); req.set(Repository.VUOROID, selectedShift.createKey()); req.set(Repository.PAIVA, selectedShift.get(Repository.PAIVA)); List<Long> excluded = new ArrayList<Long>(); Day day = (Day) selectedShift.get(Repository.PAIVA); excluded.add(day.getValue());/*www . j a v a 2 s . c o m*/ req.set(SwapRequest.EXCLUDE, excluded); req.set(Repository.CREATOR, creator); Object[] options = { TextUtil.getText("SWAP SHIFT"), TextUtil.getText("EXCLUDE DATE"), TextUtil.getText("DELETE PREVIOUS SWAP"), TextUtil.getText("CANCEL") }; String msg = TextUtil.getText("SWAP OPTIONS"); try { msg = dss.getShiftString(selectedShift.getEntity(), msg); } catch (EntityNotFoundException ex) { Logger.getLogger(Admin.class.getName()).log(Level.SEVERE, null, ex); } while (true) { int choise = JOptionPane.showOptionDialog(frame, msg + dateList(excluded), "", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); switch (choise) { case 0: try { msg = TextUtil.getText("SWAP CONFIRMATION"); msg = dss.getShiftString(selectedShift.getEntity(), msg) + dateList(excluded); int confirm = JOptionPane.showConfirmDialog(frame, msg, TextUtil.getText("SWAP SHIFT"), JOptionPane.OK_CANCEL_OPTION); if (JOptionPane.YES_OPTION == confirm) { boolean ok = dss.swapShift(req); if (ok) { JOptionPane.showMessageDialog(frame, TextUtil.getText("SwapOk")); } else { JOptionPane.showMessageDialog(frame, TextUtil.getText("SwapPending")); } } } catch (EntityNotFoundException | IOException | SMSException | AddressException ex) { ex.printStackTrace(); JOptionPane.showMessageDialog(null, ex.getMessage()); } return; case 1: Day d = DateChooser.chooseDate(TextUtil.getText("EXCLUDE DATE"), new Day(excluded.get(excluded.size() - 1))); excluded.add(d.getValue()); break; case 2: dss.deleteSwaps(memberNumber.intValue()); return; case 3: return; } } } else { JOptionPane.showMessageDialog(frame, TextUtil.getText("NO SELECTION"), TextUtil.getText("MESSAGE"), JOptionPane.INFORMATION_MESSAGE); } }
From source file:de.huxhorn.lilith.swing.MainFrame.java
public void exit() { if (applicationPreferences.isAskingBeforeQuit()) { // yes, I hate apps that ask this question... String dialogTitle = "Exit now?"; String message = "Are you really 100% sure that you want to quit?\nPlease do yourself a favour and think about it before you answer...\nExit now?"; int result = JOptionPane.showConfirmDialog(this, message, dialogTitle, JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (JOptionPane.OK_OPTION != result) { return; }/*from ww w .j a v a 2 s.c o m*/ } if (logger.isInfoEnabled()) logger.info("Exiting..."); // this probably isn't necessary since jmdns registers a shutdown hook. if (senderService != null) { senderService.stop(); // if(logger.isInfoEnabled()) logger.info("Unregistering services..."); // // this can't be done in the shutdown hook... // jmDns.unregisterAllServices(); } if (applicationPreferences.isCleaningLogsOnExit()) { deleteInactiveLogs(); } applicationPreferences.setPreviousImportPath(importFileChooser.getCurrentDirectory()); applicationPreferences.setPreviousExportPath(exportFileChooser.getCurrentDirectory()); applicationPreferences.setPreviousOpenPath(openFileChooser.getCurrentDirectory()); applicationPreferences.flush(); longTaskManager.shutDown(); System.exit(0); }