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:com.alvermont.terraj.fracplanet.ui.AbstractTerrainViewerFrame.java
private void saveImageItemActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_saveImageItemActionPerformed {//GEN-HEADEREND:event_saveImageItemActionPerformed final int choice = this.pngChooser.showSaveDialog(this); if (choice == JFileChooser.APPROVE_OPTION) { if (!this.pngChooser.getSelectedFile().isFile() || (JOptionPane.showConfirmDialog(this, "This file already exists. Do you want to\n" + "overwrite it?", "Replace File?", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)) { try { display.getCanvas().getContext().makeCurrent(); try { final File target = FileUtils.addExtension(this.pngChooser.getSelectedFile(), ".png"); Screenshot.writeToFile(target, display.getCanvas().getWidth(), display.getCanvas().getHeight()); } finally { display.getCanvas().getContext().release(); }/*from w w w . jav a2s .c o m*/ } catch (IOException ioe) { log.error("Error writing image file", ioe); JOptionPane.showMessageDialog(this, "Error: " + ioe.getMessage() + "\nCheck log file for full details", "Error Saving", JOptionPane.ERROR_MESSAGE); } } } }
From source file:ded.ui.DiagramController.java
/** Save to the current file name. If there is no file name, * prompt for a name. *///from www . j ava 2 s .co m public void saveCurrentFile() { if (this.fileName.isEmpty()) { this.chooseAndSaveToFile(); } else { if (this.importedFile) { int res = SwingUtil.confirmationBox(this, "This diagram was loaded from \"" + this.fileName + "\", which uses the old binary ER format from the " + "C++ ERED implementation. If you save the file, it " + "will be overwritten with the new JSON-based format " + "used by the Java-based Diagram Editor, which the " + "C++ ERED cannot read.\n" + "\n" + "In order to avoid confusion, it is probably best to " + "save the new file with the \".ded\" extension rather " + "than the traditional \".er\" extension so that others " + "will know to use Ded to read it.\n" + "\n" + "Overwrite with the new format anyway?", "Confirm Overwrite of Imported File", JOptionPane.YES_NO_OPTION); if (res != JOptionPane.YES_OPTION) { return; } } this.saveToNamedFile(this.fileName); } }
From source file:de.tor.tribes.ui.windows.DSWorkbenchMainFrame.java
private void showRestoreOption() { File backupFile = new File(GlobalOptions.getSelectedProfile().getProfileDirectory() + "/backup.xml"); String lastBackup = null;/*from w w w.j a v a2s. c om*/ if (backupFile.exists()) { lastBackup = new SimpleDateFormat("dd.MM.yy HH:mm:ss").format(new Date(backupFile.lastModified())); } if (lastBackup != null) { if (JOptionPaneHelper.showQuestionConfirmBox(this, "Offenbar wurde DS Workbench nicht korrekt beendet, daher kann es mglicherweise zu Datenverlust gekommen sein.\n" + "Fr das aktuelle Profil existiert ein Backup (Erstellt: " + lastBackup + "). Mchtest du dieses wiederherstellen?", "Absturz?", "Nein", "Ja") == JOptionPane.YES_OPTION) { showInfo("Wiederherstellung luft, bitte warten..."); if (performImport(backupFile, "backup").startsWith("Import erfolgreich beendet")) { showSuccess("Wiederherstellung abgeschlossen."); JOptionPaneHelper.showInformationBox(this, "Das Backup wurde erfolgreich eingespielt. Wiederhergestellte Plne und Sets tragen die Erweiterung '_backup'.", "Backup wiederhergestellt"); } else { showInfo("Wiederherstellung abgeschlossen."); JOptionPaneHelper.showInformationBox(this, "Bei der Wiederherstellung des Backups gab es Probleme. Mglicherweise sind einige Daten verloren." + " Wiederhergestellte Plne und Sets tragen die Erweiterung '_backup'.", "Backup wiederhergestellt"); } } } else { logger.debug("There is no backup. Restoring skipped."); } }
From source file:nosqltools.MainForm.java
private void connect_DBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_connect_DBActionPerformed Panel_Text.setVisible(false); Panel_Hierarchical.setVisible(false); Panel_Table.setVisible(false); Panel_Compare.setVisible(false); Panel_Compare_Upper.setVisible(false); Panel_Connect.setVisible(true); Text_MessageBar.setText(Initializations.WAITINGFORCONNECTION); Text_MessageBar.setForeground(Color.ORANGE); if (dbcon.isConnectionSuccess()) { if (dbcon.checkDatabaseConnection()) { int result = JOptionPane.showConfirmDialog(null, "A connection to MongoDB" + "already exists. Are you sure you want to disconnect and open " + "a different connection?", "Confirm", JOptionPane.YES_NO_OPTION); if (result == JOptionPane.YES_OPTION) { dbcon.closeConnection(); connect();//from w w w . j av a 2s .c o m } } else { Text_MessageBar.setText(Initializations.MONGOSERVERERROR); Text_MessageBar.setForeground(Color.RED); JOptionPane.showMessageDialog(null, Initializations.MONGOSERVERERROR, "Error", JOptionPane.ERROR_MESSAGE); } } else { connect(); } }
From source file:com.diversityarrays.kdxplore.trialmgr.trait.TraitExplorerPanel.java
private void changeEditable(boolean isLocked, boolean override) { if (isLocked) { editingLocked.setIcon(KDClientUtils.getIcon(ImageId.LOCKED)); editingLocked.setForeground(Color.BLACK); editingLocked.setText(EDITABLE_LOCKED); traitsEditable = false;/*from www . j a v a2s .c om*/ } else { TrialManagerPreferences prefs = TrialManagerPreferences.getInstance(); if (!override && prefs.getShowEditTraitWarning()) { JPanel dialogPanel = new JPanel(new BorderLayout()); JLabel dialogLabel = new JLabel( "<html>Editing <b><i>Traits</i></b> may adversely affect the <b><i>Trials</i></b> using them."); JCheckBox checkBox = new JCheckBox("Don't show me this again.", false); dialogPanel.add(dialogLabel, BorderLayout.CENTER); dialogPanel.add(checkBox, BorderLayout.SOUTH); if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(this, dialogPanel, "Allow Trait Editing?", JOptionPane.YES_NO_OPTION)) { editingLocked.setIcon(KDClientUtils.getIcon(ImageId.UNLOCKED)); editingLocked.setForeground(Color.RED); editingLocked.setText(EDITABLE_UNLOCKED); traitsEditable = true; } if (checkBox.isSelected()) { prefs.setShowEditTraitWarning(false); } } else { editingLocked.setIcon(KDClientUtils.getIcon(ImageId.UNLOCKED)); editingLocked.setForeground(Color.RED); editingLocked.setText(EDITABLE_UNLOCKED); traitsEditable = true; } } }
From source file:de.tor.tribes.ui.views.DSWorkbenchDoItYourselfAttackPlaner.java
private void copyBBToExternalClipboardEvent() { try {//from w ww. j a va2 s .c om List<Attack> attacks = getSelectedAttacks(); if (attacks.isEmpty()) { showInfo("Keine Angriffe ausgewhlt"); return; } 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]Angriffsplan[/size][/u]\n\n"); } else { buffer.append("[u]Angriffsplan[/u]\n\n"); } buffer.append(new AttackListFormatter().formatElements(attacks, 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 Angriffe 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 = "Daten in Zwischenablage kopiert."; 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:de.tor.tribes.ui.views.DSWorkbenchAttackFrame.java
/** * Initialize and add one tab for each attack plan to jTabbedPane1 *//* w w w . j av a2 s . c o m*/ public void generateAttackTabs() { jAttackTabPane.invalidate(); while (jAttackTabPane.getTabCount() > 0) { AttackTableTab tab = (AttackTableTab) jAttackTabPane.getComponentAt(0); tab.deregister(); jAttackTabPane.removeTabAt(0); } String[] plans = AttackManager.getSingleton().getGroups(); for (String plan : plans) { AttackTableTab tab = new AttackTableTab(plan, this); jAttackTabPane.addTab(plan, tab); } for (int i = 0; i < jAttackTabPane.getTabCount(); i++) { final TabPaneComponent component = new TabPaneComponent(jAttackTabPane); component.setStopEditingListener(new GenericEventListener() { @Override public void event() { int i = jAttackTabPane.indexOfTabComponent(component); AttackTableTab tab = (AttackTableTab) jAttackTabPane.getComponentAt(i); String newName = component.getEditedText(); if (!newName.equals(tab.getAttackPlan())) { newName = newName.trim(); if (newName.length() == 0) { JOptionPaneHelper.showWarningBox(jAttackTabPane, "'" + newName + "' ist ein ungltiger Planname", "Fehler"); return; } if (AttackManager.getSingleton().groupExists(newName)) { JOptionPaneHelper.showWarningBox(jAttackTabPane, "Es existiert bereits ein Plan mit dem Namen '" + newName + "'", "Fehler"); return; } AttackManager.getSingleton().renameGroup(tab.getAttackPlan(), newName); } } }); component.setCloseTabListener(new GenericEventListener() { @Override public void event() { int i = jAttackTabPane.indexOfTabComponent(component); AttackTableTab tab = (AttackTableTab) jAttackTabPane.getComponentAt(i); if (JOptionPaneHelper.showQuestionConfirmBox(jAttackTabPane, "Befehlsplan '" + tab.getAttackPlan() + "' und alle darin enthaltenen Befehle wirklich lschen? ", "Lschen", "Nein", "Ja") == JOptionPane.YES_OPTION) { AttackManager.getSingleton().removeGroup(tab.getAttackPlan()); } } }); if (i == 0 || i == 1) { component.setCloseable(false); component.setEditable(false); } jAttackTabPane.setTabComponentAt(i, component); } jAttackTabPane.revalidate(); AttackTableTab tab = getActiveTab(); if (tab != null) { tab.updatePlan(); } }
From source file:ca.osmcanada.osvuploadr.JPMain.java
private void jbAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbAddActionPerformed try {//www . j a v a2 s . c o m JFileChooser fc = new JFileChooser(); if (!last_dir.isEmpty()) { fc.setCurrentDirectory(new java.io.File(last_dir)); // start at application current directory } fc.setMultiSelectionEnabled(true); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int returnVal = fc.showSaveDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { if (fc.getSelectedFiles().length == 1) { int response = JOptionPane.showConfirmDialog(null, new String(r.getString("immediate_sub_folders").getBytes(), "UTF-8"), new String(r.getString("add_subfolders").getBytes(), "UTF-8"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.NO_OPTION) { File folder = fc.getSelectedFile(); listDir.add(folder.getPath()); last_dir = folder.getPath(); } else if (response == JOptionPane.YES_OPTION) { //Get a list of subdirectories String[] subDirs = fc.getSelectedFile().list(new FilenameFilter() { @Override public boolean accept(File current, String name) { return new File(current, name).isDirectory(); } }); for (String subDir : subDirs) { listDir.add(new File(fc.getSelectedFile() + "/" + subDir).getPath()); } } } else if (fc.getSelectedFiles().length > 1) { File[] folders = fc.getSelectedFiles(); for (File folder : folders) { listDir.add(folder.getPath()); last_dir = folder.getPath(); } } } } catch (UnsupportedEncodingException ex) { } }
From source file:com.claim.ui.UiReportType5.java
private void btn197GenReportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn197GenReportActionPerformed final DialogWaitProcess wait = new DialogWaitProcess(); try {//ww w . j a v a 2 s. c om if (comboYearType5.getSelectedIndex() != 0) { if (comboNumType5.getSelectedIndex() != 0) { if (radioDetailType5.isSelected() || radioSumType5.isSelected()) { if (radioTopic197.isSelected() || radioTopicHighcost.isSelected()) { if (radioAllHospitalType5.isSelected() || radioSingleHospitalType5.isSelected()) { if (radioAllHospitalType5.isSelected() || radioSingleHospitalType5.isSelected() && listSelectHospital.size() > 0) { if (!txtPathFileType5.getText().isEmpty()) { int selectOption = JOptionPane.showConfirmDialog(null, ConstantMessage.MSG_REPORT_CONFIRM, ConstantMessage.MSG_REPORT_INFOMATION, JOptionPane.YES_NO_OPTION); if (selectOption == JOptionPane.YES_OPTION) { wait.setVisible(true); Thread thread = new Thread(new Runnable() { @Override public void run() { ProgrameStatus programeStatus = new ProgrameStatus(); try { wait.setTitle(ConstantMessage.MSG_PROGRAME_PROCESSSING); if (radioDetailType5.isSelected()) { // // status = individualController.op_individual_detail_MutiSheet(setInputFormReport()); programeStatus = type5Controller .type5_detail(setInputFormReport()); if (programeStatus.getProcessStatus()) { JOptionPane.showMessageDialog(UiReportType5.this, programeStatus.getMessage(), programeStatus.getTitle(), JOptionPane.INFORMATION_MESSAGE); baseFunction.openDirectoryAutomatic( setInputFormReport().getPathFile()); } else { JOptionPane.showMessageDialog(UiReportType5.this, programeStatus.getMessage(), programeStatus.getTitle(), JOptionPane.ERROR_MESSAGE); } } else { // programeStatus = type5Controller .type5_summary(setInputFormReport()); if (programeStatus.getProcessStatus()) { JOptionPane.showMessageDialog(UiReportType5.this, programeStatus.getMessage(), programeStatus.getTitle(), JOptionPane.INFORMATION_MESSAGE); baseFunction.openDirectoryAutomatic( setInputFormReport().getPathFile()); } else { JOptionPane.showMessageDialog(UiReportType5.this, programeStatus.getMessage(), programeStatus.getTitle(), JOptionPane.ERROR_MESSAGE); } } wait.setVisible(false); } catch (Exception e) { e.printStackTrace(); } /* * 17-08-2015 */ /*try { new LogAppController().createLog("??", "?? type5 ? ?? ", NetUtils.getIpAddress(), 1); } catch (UnknownHostException ex) { Logger.getLogger(UiMainClaim.class.getName()).log(Level.SEVERE, null, ex); }*/ } }); thread.start(); } } else { JOptionPane.showMessageDialog(this, ConstantMessage.MSG_FILE_LOCATION_PLEASE, ConstantMessage.MSG_FILE_LOCATION, JOptionPane.ERROR_MESSAGE); } } else { JOptionPane.showMessageDialog(this, ConstantMessage.MSG_HOSPITAL_SELECT_PLEASE, ConstantMessage.MSG_SELECT_DATA, JOptionPane.ERROR_MESSAGE); } } else { JOptionPane.showMessageDialog(this, ConstantMessage.MSG_HOSPITAL_ATTRIBUTE, ConstantMessage.MSG_SELECT_DATA, JOptionPane.ERROR_MESSAGE); } } else { JOptionPane.showMessageDialog(this, ConstantMessage.MSG_197_HIGTHCOST, ConstantMessage.MSG_SELECT_DATA, JOptionPane.ERROR_MESSAGE); } } else { JOptionPane.showMessageDialog(this, ConstantMessage.MSG_REPOTR_FORMAT, ConstantMessage.MSG_SELECT_DATA, JOptionPane.ERROR_MESSAGE); } } else { JOptionPane.showMessageDialog(this, ConstantMessage.MSG_SELECT_NO, ConstantMessage.MSG_SELECT_DATA, JOptionPane.ERROR_MESSAGE); } } else { JOptionPane.showMessageDialog(this, ConstantMessage.MSG_SELECT_DATE_PLEASE, ConstantMessage.MSG_SELECT_DATA, JOptionPane.ERROR_MESSAGE); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.alvermont.terraj.fracplanet.ui.AbstractTerrainViewerFrame.java
private void exitItemActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_exitItemActionPerformed {//GEN-HEADEREND:event_exitItemActionPerformed if (JOptionPane.showConfirmDialog(this, "Are you sure you want to exit?", "Confirm Exit", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { this.setVisible(false); System.exit(1);//from www. ja v a 2s . com } }