List of usage examples for javax.swing JOptionPane showConfirmDialog
public static int showConfirmDialog(Component parentComponent, Object message, String title, int optionType) throws HeadlessException
optionType
parameter. From source file:be.agiv.security.demo.Main.java
private void rStsIssueToken() { GridBagLayout gridBagLayout = new GridBagLayout(); GridBagConstraints gridBagConstraints = new GridBagConstraints(); JPanel contentPanel = new JPanel(gridBagLayout); JLabel urlLabel = new JLabel("URL:"); gridBagConstraints.gridx = 0;/*from ww w . ja va 2 s .co m*/ gridBagConstraints.gridy = 0; gridBagConstraints.anchor = GridBagConstraints.WEST; gridBagConstraints.ipadx = 5; gridBagLayout.setConstraints(urlLabel, gridBagConstraints); contentPanel.add(urlLabel); JTextField urlTextField = new JTextField( "https://auth.beta.agiv.be/sts/Services/SalvadorSecurityTokenServiceConfiguration.svc/IWSTrust13", 60); gridBagConstraints.gridx++; gridBagLayout.setConstraints(urlTextField, gridBagConstraints); contentPanel.add(urlTextField); JLabel appliesToLabel = new JLabel("Applies to:"); gridBagConstraints.gridx = 0; gridBagConstraints.gridy++; gridBagLayout.setConstraints(appliesToLabel, gridBagConstraints); contentPanel.add(appliesToLabel); JTextField appliesToTextField = new JTextField(ClaimsAwareServiceFactory.SERVICE_REALM, 60); gridBagConstraints.gridx++; gridBagLayout.setConstraints(appliesToTextField, gridBagConstraints); contentPanel.add(appliesToTextField); int result = JOptionPane.showConfirmDialog(this, contentPanel, "R-STS Issue Token", JOptionPane.OK_CANCEL_OPTION); if (result == JOptionPane.CANCEL_OPTION) { return; } String location = urlTextField.getText(); String appliesTo = appliesToTextField.getText(); RSTSClient rStsClient = new RSTSClient(location); try { this.rStsSecurityToken = rStsClient.getSecurityToken(this.ipStsSecurityToken, appliesTo); this.rStsViewMenuItem.setEnabled(true); this.secConvIssueMenuItem.setEnabled(true); rStsViewToken(); } catch (Exception e) { showException(e); } }
From source file:net.sf.jabref.gui.exporter.SaveDatabaseAction.java
/** * Run the "Save as" operation. This method offloads the actual save operation to a background thread, but * still runs synchronously using Spin (the method returns only after completing the operation). *///from w w w.j ava2 s .c om public void saveAs() throws Throwable { String chosenFile; File f = null; while (f == null) { chosenFile = FileDialogs.getNewFile(frame, new File(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY)), Collections.singletonList(".bib"), JFileChooser.SAVE_DIALOG, false, null); if (chosenFile == null) { canceled = true; return; // canceled } f = new File(chosenFile); // Check if the file already exists: if (f.exists() && (JOptionPane.showConfirmDialog(frame, Localization.lang("'%0' exists. Overwrite file?", f.getName()), Localization.lang("Save database"), JOptionPane.OK_CANCEL_OPTION) != JOptionPane.OK_OPTION)) { f = null; } } File oldFile = panel.getBibDatabaseContext().getDatabaseFile(); panel.getBibDatabaseContext().setDatabaseFile(f); Globals.prefs.put(JabRefPreferences.WORKING_DIRECTORY, f.getParent()); runCommand(); // If the operation failed, revert the file field and return: if (!success) { panel.getBibDatabaseContext().setDatabaseFile(oldFile); return; } // Register so we get notifications about outside changes to the file. try { panel.setFileMonitorHandle(Globals.getFileUpdateMonitor().addUpdateListener(panel, panel.getBibDatabaseContext().getDatabaseFile())); } catch (IOException ex) { LOGGER.error("Problem registering file change notifications", ex); } frame.getFileHistory().newFile(panel.getBibDatabaseContext().getDatabaseFile().getPath()); frame.updateEnabledState(); }
From source file:com.biosis.sgb.vistas.dialogos.PersonaCRUD.java
private void btnEliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEliminarActionPerformed // TODO add your handling code here: this.accion = ELIMINAR; if (JOptionPane.showConfirmDialog(this, "Est seguro que desea eliminar esta persona?", "Mensaje del sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { if (this.personaControlador.accion(accion)) { FormularioUtil.mensajeExito(this, accion); this.persona = null; this.dispose(); }// w w w . j a v a 2 s. c o m } }
From source file:condorclient.MainFXMLController.java
@FXML void deleteButtonFired(ActionEvent event) { int delNo = 0; int n = JOptionPane.showConfirmDialog(null, "??", "", JOptionPane.YES_NO_OPTION); if (n == JOptionPane.YES_OPTION) { URL url = null;/*w w w .java2 s . c o m*/ XMLHandler handler = new XMLHandler(); String scheddStr = handler.getURL("schedd"); try { url = new URL(scheddStr); // url = new URL("http://localhost:9628"); } catch (MalformedURLException e3) { // TODO Auto-generated catch block e3.printStackTrace(); } Schedd schedd = null; try { schedd = new Schedd(url); } catch (ServiceException ex) { Logger.getLogger(CondorClient.class.getName()).log(Level.SEVERE, null, ex); } //ClassAdStructAttr[] ClassAd ad = null;//birdbath.ClassAd; ClassAdStructAttr[][] classAdArray = null; int cluster = 0; int job = 0; Transaction xact = schedd.createTransaction(); try { xact.begin(30); } catch (RemoteException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } final List<?> selectedNodeList = new ArrayList<>(table.getSelectionModel().getSelectedItems()); String taskStatus = ""; for (Object o : selectedNodeList) { if (o instanceof ObservableDisplayedClassAd) { delNo = Integer.parseInt(((ObservableDisplayedClassAd) o).getClusterId()); taskStatus = ((ObservableDisplayedClassAd) o).getJobStatus(); if (taskStatus.equals("")) { JOptionPane.showMessageDialog(null, "?"); return; } String findreq = "owner==\"" + condoruser + "\"&&ClusterId==" + delNo; try { classAdArray = schedd.getJobAds(findreq); } catch (RemoteException ex) { Logger.getLogger(MainFXMLController.class.getName()).log(Level.SEVERE, null, ex); } for (ClassAdStructAttr[] x : classAdArray) { ad = new ClassAd(x); job = Integer.parseInt(ad.get("ProcId")); try { xact.closeSpool(delNo, job); // System.out.print("ts.getClusterId():" + showClusterId + "\n"); } catch (RemoteException ex) { Logger.getLogger(MainFXMLController.class.getName()).log(Level.SEVERE, null, ex); } } try { xact.removeCluster(delNo, ""); } catch (RemoteException ex) { Logger.getLogger(MainFXMLController.class.getName()).log(Level.SEVERE, null, ex); } } } //end try { xact.commit(); } catch (RemoteException e) { e.printStackTrace(); } //?? // XMLHandler handler = new XMLHandler(); int delNo1[] = new int[1];// delNo1[0] = delNo; handler.removeJobs(delNo1, 1); } else if (n == JOptionPane.NO_OPTION) { System.out.println("qu xiao"); } }
From source file:com.firmansyah.imam.sewa.kendaraan.FormUser.java
private void btnKeluarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnKeluarActionPerformed int dialogButton = JOptionPane.YES_NO_OPTION; int dialogResult; dialogResult = JOptionPane.showConfirmDialog(this, "Anda Yakin Ingin Keluar? ", "Konfirmasi", dialogButton); if (dialogResult == 0) { System.out.println("Quit"); this.dispose(); } else {/*from www . j a va2 s . c om*/ System.out.println("cancel"); } }
From source file:e3fraud.gui.MainWindow.java
public void actionPerformed(ActionEvent e) { //Handle open button action. if (e.getSource() == openButton) { int returnVal = fc.showOpenDialog(MainWindow.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); //parse file this.baseModel = FileParser.parseFile(file); log.append(currentTime.currentTime() + " Opened: " + file.getName() + "." + newline); } else {/* www.j a va2 s . c o m*/ log.append(currentTime.currentTime() + " Open command cancelled by user." + newline); } log.setCaretPosition(log.getDocument().getLength()); //handle Generate button } else if (e.getSource() == generateButton) { if (this.baseModel != null) { //have the user indicate the ToA via pop-up JFrame frame1 = new JFrame("Select Target of Assessment"); Map<String, Resource> actorsMap = this.baseModel.getActorsMap(); String selectedActorString = (String) JOptionPane.showInputDialog(frame1, "Which actor's perspective are you taking?", "Choose main actor", JOptionPane.QUESTION_MESSAGE, null, actorsMap.keySet().toArray(), actorsMap.keySet().toArray()[0]); if (selectedActorString == null) { log.append(currentTime.currentTime() + " Attack generation cancelled!" + newline); } else { lastSelectedActorString = selectedActorString; //have the user select a need via pop-up JFrame frame2 = new JFrame("Select graph parameter"); Map<String, Resource> needsMap = this.baseModel.getNeedsMap(); String selectedNeedString = (String) JOptionPane.showInputDialog(frame2, "What do you want to use as parameter?", "Choose need to parametrize", JOptionPane.QUESTION_MESSAGE, null, needsMap.keySet().toArray(), needsMap.keySet().toArray()[0]); if (selectedNeedString == null) { log.append("Attack generation cancelled!" + newline); } else { lastSelectedNeedString = selectedNeedString; //have the user select occurence interval via pop-up JTextField xField = new JTextField("1", 4); JTextField yField = new JTextField("500", 4); JPanel myPanel = new JPanel(); myPanel.add(new JLabel("Mininum occurences:")); myPanel.add(xField); myPanel.add(Box.createHorizontalStrut(15)); // a spacer myPanel.add(new JLabel("Maximum occurences:")); myPanel.add(yField); int result = JOptionPane.showConfirmDialog(null, myPanel, "Please Enter occurence rate interval", JOptionPane.OK_CANCEL_OPTION); if (result == JOptionPane.CANCEL_OPTION) { log.append("Attack generation cancelled!" + newline); } else if (result == JOptionPane.OK_OPTION) { startValue = Integer.parseInt(xField.getText()); endValue = Integer.parseInt(yField.getText()); selectedNeed = needsMap.get(selectedNeedString); selectedActor = actorsMap.get(selectedActorString); //Have a Worker thread to the time-consuming generation and raking (to not freeze the GUI) GenerationWorker generationWorker = new GenerationWorker(baseModel, selectedActorString, selectedActor, selectedNeed, selectedNeedString, startValue, endValue, log, lossButton, gainButton, lossGainButton, gainLossButton, groupingButton, collusionsButton) { //make it so that when Worker is done @Override protected void done() { try { progressBar.setVisible(false); System.err.println("I made it invisible"); //the Worker's result is retrieved treeModel.setRoot(get()); tree.setModel(treeModel); tree.updateUI(); tree.collapseRow(1); //tree.expandRow(0); tree.setRootVisible(false); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } catch (InterruptedException | ExecutionException ex) { Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); log.append("Out of memory; please increase heap size of JVM"); PopUps.infoBox( "Encountered an error. Most likely out of memory; try increasing the heap size of JVM", "Error"); } } }; this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); progressBar.setVisible(true); progressBar.setIndeterminate(true); progressBar.setString("generating..."); generationWorker.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if ("phase".equals(evt.getPropertyName())) { progressBar.setMaximum(100); progressBar.setIndeterminate(false); progressBar.setString("ranking..."); } else if ("progress".equals(evt.getPropertyName())) { progressBar.setValue((Integer) evt.getNewValue()); } } }); generationWorker.execute(); } } } } else { log.append("Load a model file first!" + newline); } } //handle the refresh button else if (e.getSource() == refreshButton) { if (lastSelectedNeedString != null && lastSelectedActorString != null) { Map<String, Resource> actorsMap = this.baseModel.getActorsMap(); Map<String, Resource> needsMap = this.baseModel.getNeedsMap(); selectedNeed = needsMap.get(lastSelectedNeedString); selectedActor = actorsMap.get(lastSelectedActorString); //Have a Worker thread to the time-consuming generation and raking (to not freeze the GUI) GenerationWorker generationWorker = new GenerationWorker(baseModel, lastSelectedActorString, selectedActor, selectedNeed, lastSelectedNeedString, startValue, endValue, log, lossButton, gainButton, lossGainButton, gainLossButton, groupingButton, collusionsButton) { //make it so that when Worker is done @Override protected void done() { try { progressBar.setVisible(false); //the Worker's result is retrieved treeModel.setRoot(get()); tree.setModel(treeModel); tree.updateUI(); tree.collapseRow(1); //tree.expandRow(0); tree.setRootVisible(false); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } catch (InterruptedException | ExecutionException ex) { Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); log.append("Most likely out of memory; please increase heap size of JVM"); PopUps.infoBox( "Encountered an error. Most likely out of memory; try increasing the heap size of JVM", "Error"); } } }; setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); progressBar.setVisible(true); progressBar.setIndeterminate(true); progressBar.setString("generating..."); generationWorker.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if ("phase".equals(evt.getPropertyName())) { progressBar.setMaximum(100); progressBar.setIndeterminate(false); progressBar.setString("ranking..."); } else if ("progress".equals(evt.getPropertyName())) { progressBar.setValue((Integer) evt.getNewValue()); } } }); generationWorker.execute(); } else { log.append(currentTime.currentTime() + " Nothing to refresh. Generate models first" + newline); } } //handle show ideal graph button else if (e.getSource() == idealGraphButton) { if (this.baseModel != null) { graph1 = GraphingTool.generateGraph(baseModel, selectedNeed, startValue, endValue, true);//expected graph ChartFrame chartframe1 = new ChartFrame("Ideal results", graph1); chartframe1.setPreferredSize(new Dimension(CHART_WIDTH, CHART_HEIGHT)); chartframe1.pack(); chartframe1.setLocationByPlatform(true); chartframe1.setVisible(true); } else { log.append(currentTime.currentTime() + " Load a model file first!" + newline); } } //Handle the graph extend button//Handle the graph extend button else if (e.getSource() == expandButton) { //make sure there is a graph to show if (graph2 == null) { log.append(currentTime.currentTime() + " No graph to display. Select one first." + newline); } else { //this makes sure both graphs have the same y axis: // double lowerBound = min(graph1.getXYPlot().getRangeAxis().getRange().getLowerBound(), graph2.getXYPlot().getRangeAxis().getRange().getLowerBound()); // double upperBound = max(graph1.getXYPlot().getRangeAxis().getRange().getUpperBound(), graph2.getXYPlot().getRangeAxis().getRange().getUpperBound()); // graph1.getXYPlot().getRangeAxis().setRange(lowerBound, upperBound); // graph2.getXYPlot().getRangeAxis().setRange(lowerBound, upperBound); chartPane.removeAll(); chartPanel = new ChartPanel(graph2); chartPanel.setPreferredSize(new Dimension(CHART_WIDTH, CHART_HEIGHT)); chartPane.add(chartPanel); chartPane.add(collapseButton); extended = true; this.setPreferredSize(new Dimension(this.getWidth() + CHART_WIDTH, this.getHeight())); JFrame frame = (JFrame) getRootPane().getParent(); frame.pack(); } } //Handle the graph collapse button//Handle the graph collapse button else if (e.getSource() == collapseButton) { System.out.println("resizing by -" + CHART_WIDTH); chartPane.removeAll(); chartPane.add(expandButton); this.setPreferredSize(new Dimension(this.getWidth() - CHART_WIDTH, this.getHeight())); chartPane.repaint(); chartPane.revalidate(); extended = false; JFrame frame = (JFrame) getRootPane().getParent(); frame.pack(); } }
From source file:gov.nij.er.ui.EntityResolutionDemo.java
private int promptParametersFileOverwrite() { return JOptionPane.showConfirmDialog(this, "The file exists, overwrite?", "Existing file", JOptionPane.YES_NO_CANCEL_OPTION); }
From source file:fll.scheduler.SchedulerUI.java
private void newScheduleDescription() { final int result = JOptionPane.showConfirmDialog(SchedulerUI.this, "This action will remove any changes to the current schedule and load the defaults. Do you want to continue?", "Question", JOptionPane.YES_NO_OPTION); if (JOptionPane.YES_OPTION == result) { mScheduleDescriptionFile = null; mDescriptionFilename.setText(""); final SolverParams params = new SolverParams(); mScheduleDescriptionEditor.setParams(params); }/* ww w . ja v a 2 s . c om*/ }
From source file:net.sf.profiler4j.console.Console.java
public void applyRules() { int ret = JOptionPane.showConfirmDialog(mainFrame, "Request activation of profiling rules now? (This may take some time)", "Activate Profiling Rules", JOptionPane.OK_CANCEL_OPTION); if (ret != JOptionPane.OK_OPTION) { return;/*from ww w. ja v a2 s . co m*/ } LongTask t = new LongTask() { public void executeInBackground() throws Exception { setTaskMessage("Activating profiling rules..."); client.applyRules(project.formatRules(), project.formatOptions(), new ProgressCallback() { private int max; public void operationStarted(int amount) { max = amount; setTaskProgress(0); } public void update(int value) { setTaskProgress((value * 100) / max); setTaskMessage("Activating profiling rules... (class " + value + " of " + max + ")"); } }); }; }; runInBackground(t); if (t.getError() == null) { sendEvent(AppEventType.RULES_APPLIED); } }
From source file:org.obiba.onyx.jade.instrument.ricelake.RiceLakeWeightInstrumentRunner.java
/** * Displays a confirmation window when the application is closed by the user without saving. *//*w w w .ja va 2 s . c om*/ protected void confirmOnExit() { // Ask for confirmation only if data has been fetch from the device. if (saveButton.isEnabled()) { int wConfirmation = JOptionPane.showConfirmDialog(appWindow, resourceBundle.getString("Confirmation.Close_window"), resourceBundle.getString("Title.Confirmation"), JOptionPane.YES_NO_OPTION); // If confirmed, application is closed. if (wConfirmation == JOptionPane.YES_OPTION) { exitUI(); } } else { exitUI(); } }