List of usage examples for javax.swing JOptionPane YES_OPTION
int YES_OPTION
To view the source code for javax.swing JOptionPane YES_OPTION.
Click Source Link
From source file:condorclient.MainFXMLController.java
@FXML void pauseButtonFired(ActionEvent event) { int delNo = 0; int pauseId = 0; int n = JOptionPane.showConfirmDialog(null, "??", "", JOptionPane.YES_NO_OPTION); if (n == JOptionPane.YES_OPTION) { //checkboxclusterId System.out.print(Thread.currentThread().getName() + "\n"); URL url = null;// w w w. j ava2s . c om XMLHandler handler = new XMLHandler(); String scheddStr = handler.getURL("schedd"); try { url = new URL(scheddStr); } 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[] int boxToClusterId; ClassAd ad = null;//birdbath.ClassAd; ClassAdStructAttr[][] classAdArray = null; Transaction xact = schedd.createTransaction(); try { xact.begin(30); } catch (RemoteException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } int job = 0; //s final List<?> selectedNodeList = new ArrayList<>(table.getSelectionModel().getSelectedItems()); for (Object o : selectedNodeList) { if (o instanceof ObservableDisplayedClassAd) { pauseId = Integer.parseInt(((ObservableDisplayedClassAd) o).getClusterId()); } } //e String findreq = "owner==\"" + condoruser + "\"&&ClusterId==" + pauseId; try { classAdArray = schedd.getJobAds(findreq); } catch (RemoteException ex) { Logger.getLogger(MainFXMLController.class.getName()).log(Level.SEVERE, null, ex); } String showJobStatus = null; for (ClassAdStructAttr[] x : classAdArray) { ad = new ClassAd(x); job = Integer.parseInt(ad.get("ProcId")); status = Integer.valueOf(ad.get("JobStatus")); showJobStatus = statusName[status]; try { if (showJobStatus.equals("") || showJobStatus.equals("?") || showJobStatus.equals("")) { xact.holdJob(pauseId, job, ""); } else {//?? if (showJobStatus.equals("?") || showJobStatus.equals("")) { JOptionPane.showMessageDialog(null, "?????"); return; } } // System.out.print("ts.getClusterId():" + showClusterId + "\n"); } catch (RemoteException ex) { Logger.getLogger(MainFXMLController.class.getName()).log(Level.SEVERE, null, ex); } } try { xact.commit(); } catch (RemoteException e) { e.printStackTrace(); } } else if (n == JOptionPane.NO_OPTION) { System.out.println("qu xiao"); } }
From source file:gdt.jgui.entity.webset.JWeblinksPanel.java
/** * Get the context menu.// w w w .j a va2s .c o 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:com.tiempometa.muestradatos.JMuestraDatos.java
private void menuItem2ActionPerformed(ActionEvent e) { int response = JOptionPane.showConfirmDialog(null, "Seguro que deseas cerrar la aplicacin?", "Cerrar Programa", JOptionPane.WARNING_MESSAGE); if (response == JOptionPane.YES_OPTION) { ReaderContext.stopReading();//from w w w . jav a 2s .c o m try { Thread.sleep(2000); } catch (InterruptedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { ReaderContext.disconnectUsbReader(); } catch (ReaderException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } this.dispose(); } }
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) { //// w ww . j a v a2 s. c o m 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:captureplugin.drivers.defaultdriver.AdditionalParams.java
/** * Remove was pressed/*from w w w . j av a 2s. c o m*/ */ protected void removePressed() { if (mList.getSelectedValue() == null) { return; } mDeleting = true; int result = JOptionPane.showConfirmDialog(this, mLocalizer.msg("Delete", "Delete Parameter?"), mLocalizer.msg("Additional", "Additional Parameters"), JOptionPane.YES_NO_OPTION); if (result == JOptionPane.YES_OPTION) { mSelectedEntry = null; int num = mList.getSelectedIndex(); mListModel.removeElement(mList.getSelectedValue()); if (num + 1 > mListModel.size()) { mList.setSelectedIndex(mListModel.size() - 1); } else if (mListModel.size() > 0) { mList.setSelectedIndex(num); } } mDeleting = false; }
From source file:com.floreantpos.config.ui.DatabaseConfigurationDialog.java
public void actionPerformed(ActionEvent e) { try {/*from ww w . j a v a2s . c o m*/ String command = e.getActionCommand(); Database selectedDb = (Database) databaseCombo.getSelectedItem(); final String providerName = selectedDb.getProviderName(); final String databaseURL = tfServerAddress.getText(); final String databasePort = tfServerPort.getText(); final String databaseName = tfDatabaseName.getText(); final String user = tfUserName.getText(); final String pass = new String(tfPassword.getPassword()); final String connectionString = selectedDb.getConnectString(databaseURL, databasePort, databaseName); final String hibernateDialect = selectedDb.getHibernateDialect(); final String driverClass = selectedDb.getHibernateConnectionDriverClass(); if (CANCEL.equalsIgnoreCase(command)) { dispose(); return; } setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); Application.getInstance().setSystemInitialized(false); saveConfig(selectedDb, providerName, databaseURL, databasePort, databaseName, user, pass, connectionString, hibernateDialect); if (TEST.equalsIgnoreCase(command)) { try { DatabaseUtil.checkConnection(connectionString, hibernateDialect, driverClass, user, pass); } catch (DatabaseConnectionException e1) { JOptionPane.showMessageDialog(this, Messages.getString("DatabaseConfigurationDialog.32")); //$NON-NLS-1$ return; } connectionSuccess = true; JOptionPane.showMessageDialog(this, Messages.getString("DatabaseConfigurationDialog.31")); //$NON-NLS-1$ } else if (UPDATE_DATABASE.equals(command)) { int i = JOptionPane.showConfirmDialog(this, Messages.getString("DatabaseConfigurationDialog.0"), //$NON-NLS-1$ Messages.getString("DatabaseConfigurationDialog.1"), JOptionPane.YES_NO_OPTION); //$NON-NLS-1$ if (i != JOptionPane.YES_OPTION) { return; } //isAuthorizedToPerformDbChange(); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); boolean databaseUpdated = DatabaseUtil.updateDatabase(connectionString, hibernateDialect, driverClass, user, pass); if (databaseUpdated) { connectionSuccess = true; JOptionPane.showMessageDialog(DatabaseConfigurationDialog.this, Messages.getString("DatabaseConfigurationDialog.2")); //$NON-NLS-1$ } else { JOptionPane.showMessageDialog(DatabaseConfigurationDialog.this, Messages.getString("DatabaseConfigurationDialog.3")); //$NON-NLS-1$ } } else if (CREATE_DATABASE.equals(command)) { int i = JOptionPane.showConfirmDialog(this, Messages.getString("DatabaseConfigurationDialog.33"), //$NON-NLS-1$ Messages.getString("DatabaseConfigurationDialog.34"), JOptionPane.YES_NO_OPTION); //$NON-NLS-1$ if (i != JOptionPane.YES_OPTION) { return; } i = JOptionPane.showConfirmDialog(this, Messages.getString("DatabaseConfigurationDialog.4"), //$NON-NLS-1$ Messages.getString("DatabaseConfigurationDialog.5"), JOptionPane.YES_NO_OPTION); //$NON-NLS-1$ boolean generateSampleData = false; if (i == JOptionPane.YES_OPTION) generateSampleData = true; setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); String createDbConnectString = selectedDb.getCreateDbConnectString(databaseURL, databasePort, databaseName); boolean databaseCreated = DatabaseUtil.createDatabase(createDbConnectString, hibernateDialect, driverClass, user, pass, generateSampleData); if (databaseCreated) { JOptionPane.showMessageDialog(DatabaseConfigurationDialog.this, Messages.getString("DatabaseConfigurationDialog.6") + //$NON-NLS-1$ Messages.getString("DatabaseConfigurationDialog.7")); //$NON-NLS-1$ Main.restart(); connectionSuccess = true; } else { JOptionPane.showMessageDialog(DatabaseConfigurationDialog.this, Messages.getString("DatabaseConfigurationDialog.36")); //$NON-NLS-1$ } } else if (SAVE.equalsIgnoreCase(command)) { if (connectionSuccess) { Application.getInstance().initializeSystem(); } dispose(); } } catch (Exception e2) { PosLog.error(getClass(), e2); POSMessageDialog.showMessage(this, e2.getMessage()); } finally { setCursor(Cursor.getDefaultCursor()); } }
From source file:net.sf.keystore_explorer.gui.dialogs.DViewCertCsrPem.java
private void exportPressed() { File chosenFile = null;// ww w . j a v a 2 s .c o m FileWriter fw = null; String title; if (cert != null) { title = res.getString("DViewCertCsrPem.ExportPemCertificate.Title"); } else { title = res.getString("DViewCertCsrPem.ExportPemCsr.Title"); } try { String certPem = jtaPem.getText(); JFileChooser chooser = FileChooserFactory.getX509FileChooser(); chooser.setCurrentDirectory(CurrentDirectory.get()); chooser.setDialogTitle(title); chooser.setMultiSelectionEnabled(false); int rtnValue = JavaFXFileChooser.isFxAvailable() ? chooser.showSaveDialog(this) : chooser.showDialog(this, res.getString("DViewCertCsrPem.ChooseExportFile.button")); if (rtnValue != JFileChooser.APPROVE_OPTION) { return; } chosenFile = chooser.getSelectedFile(); CurrentDirectory.updateForFile(chosenFile); if (chosenFile.isFile()) { String message = MessageFormat.format(res.getString("DViewCertCsrPem.OverWriteFile.message"), chosenFile); int selected = JOptionPane.showConfirmDialog(this, message, title, JOptionPane.YES_NO_OPTION); if (selected != JOptionPane.YES_OPTION) { return; } } fw = new FileWriter(chosenFile); fw.write(certPem); } catch (FileNotFoundException ex) { JOptionPane.showMessageDialog(this, MessageFormat.format(res.getString("DViewCertCsrPem.NoWriteFile.message"), chosenFile), title, JOptionPane.WARNING_MESSAGE); return; } catch (Exception ex) { DError.displayError(this, ex); return; } finally { IOUtils.closeQuietly(fw); } JOptionPane.showMessageDialog(this, res.getString("DViewCertCsrPem.ExportPemCertificateSuccessful.message"), title, JOptionPane.INFORMATION_MESSAGE); }
From source file:de.tor.tribes.ui.views.DSWorkbenchFormFrame.java
private void copySelectionToInternalClipboardAsBBCodes() { try {/*from w ww . j av a 2s.co m*/ List<AbstractForm> forms = getSelectedForms(); if (forms.isEmpty()) { showInfo("Keine Zeichnungen ausgewhlt"); return; } int ignoredForms = 0; for (AbstractForm form : forms) { if (!form.allowsBBExport()) { ignoredForms++; } } boolean extended = (JOptionPaneHelper.showQuestionConfirmBox(this, "Erweiterte BB-Codes verwenden (nur fr Forum und Notizen geeignet)?", "Erweiterter BB-Code", "Nein", "Ja") == JOptionPane.YES_OPTION); StringBuilder buffer = new StringBuilder(); if (extended) { buffer.append("[u][size=12]Zeichnungen[/size][/u]\n\n"); } else { buffer.append("[u]Zeichnungen[/u]\n\n"); } buffer.append(new FormListFormatter().formatElements(forms, extended)); if (extended) { buffer.append("\n[size=8]Erstellt am "); buffer.append( new SimpleDateFormat("dd.MM.yy 'um' HH:mm:ss").format(Calendar.getInstance().getTime())); buffer.append(" mit DS Workbench "); buffer.append(Constants.VERSION).append(Constants.VERSION_ADDITION + "[/size]\n"); } else { buffer.append("\nErstellt am "); buffer.append( new SimpleDateFormat("dd.MM.yy 'um' HH:mm:ss").format(Calendar.getInstance().getTime())); buffer.append(" mit DS Workbench "); buffer.append(Constants.VERSION).append(Constants.VERSION_ADDITION + "\n"); } String b = buffer.toString(); StringTokenizer t = new StringTokenizer(b, "["); int cnt = t.countTokens(); if (cnt > 1000) { if (JOptionPaneHelper.showQuestionConfirmBox(this, "Die ausgewhlten Zeichnungen bentigen mehr als 1000 BB-Codes\n" + "und knnen daher im Spiel (Forum/IGM/Notizen) nicht auf einmal dargestellt werden.\nTrotzdem exportieren?", "Zu viele BB-Codes", "Nein", "Ja") == JOptionPane.NO_OPTION) { return; } } Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(b), null); String result = null; if (ignoredForms != forms.size()) { result = "<html>Daten in Zwischenablage kopiert."; if (ignoredForms > 0) { result += ((ignoredForms == 1) ? " Eine Zeichnung wurde" : " " + ignoredForms + " Zeichnungen wurden") + " ignoriert, da der BB-Export nur fr Rechtecke, Kreise und Freihandzeichnungen verfügbar ist."; } result += "</html>"; } else { showError( "<html>Keine Zeichnungen exportiert, da der BB-Export nur fr Rechtecke, Kreise und Freihandzeichnungen verfügbar ist.</html>"); return; } showSuccess(result); } catch (Exception e) { logger.error("Failed to copy data to clipboard", e); String result = "Fehler beim Kopieren in die Zwischenablage."; showError(result); } }
From source file:QueryConnector.java
private static boolean confirm(String msg) { return JOptionPane.showConfirmDialog(null, msg, tr("CONFIRM_DIALOG_TITLE"), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION; }
From source file:com.qframework.core.GameonApp.java
private void onTextInput(final String resptype, final String respdata) { Timer t = new javax.swing.Timer(50, new ActionListener() { public void actionPerformed(ActionEvent e) { JTextField area = new JTextField(resptype); area.setFocusable(true);/*from w ww . j a v a 2 s. c o m*/ area.requestFocus(); Object options[] = new Object[] { area }; Frame parent = null; if (mAppContext != null) parent = (Frame) SwingUtilities.getAncestorOfClass(java.awt.Frame.class, mAppContext); else parent = (Frame) SwingUtilities.getAncestorOfClass(java.awt.Frame.class, mAppletContext); int option = JOptionPane.showOptionDialog(parent, options, "", JOptionPane.YES_OPTION, JOptionPane.INFORMATION_MESSAGE, null, null, null); if (option == JOptionPane.YES_OPTION) { String truncated = area.getText().replaceAll("[^A-Za-z0-9:.@ ]", ""); String script = respdata + "('" + truncated + "' , 1);"; mScript.execScript(script); } else { String script = respdata + "(undefined, 1);"; mScript.execScript(script); } } }); t.setRepeats(false); t.start(); }