List of usage examples for javax.swing JOptionPane showOptionDialog
@SuppressWarnings("deprecation") public static int showOptionDialog(Component parentComponent, Object message, String title, int optionType, int messageType, Icon icon, Object[] options, Object initialValue) throws HeadlessException
initialValue
parameter and the number of choices is determined by the optionType
parameter. From source file:edu.ku.brc.af.ui.forms.formatters.UIFormatterEditorDlg.java
@Override protected void okButtonPressed() { if (fieldsPanel.getEditBtn().isEnabled()) { int userChoice = JOptionPane.NO_OPTION; Object[] options = { getResourceString("Continue"), //$NON-NLS-1$ getResourceString("CANCEL") //$NON-NLS-1$ };// w w w . jav a2s . co m loadAndPushResourceBundle("masterusrpwd"); userChoice = JOptionPane.showOptionDialog(this, getResourceString("UIFEDlg.ITEM_CHG"), //$NON-NLS-1$ getResourceString("UIFEDlg.CHG_TITLE"), //$NON-NLS-1$ JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (userChoice == JOptionPane.NO_OPTION) { return; } } super.okButtonPressed(); getDataFromUI(); }
From source file:com.paniclauncher.data.Settings.java
/** * Load the users Console preference from file *//* w w w .j av a 2 s . co m*/ public void loadStartingProperties() { try { if (!propertiesFile.exists()) { propertiesFile.createNewFile(); } } catch (IOException e) { String[] options = { "OK" }; JOptionPane.showOptionDialog(null, "<html><center>Cannot create the config file.<br/><br/>Make sure" + " you are running the Launcher from somewhere with<br/>write" + " permissions for your user account such as your Home/Users folder" + " or desktop.</center></html>", "Warning", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE, null, options, options[0]); System.exit(0); } try { this.properties.load(new FileInputStream(propertiesFile)); this.enableConsole = Boolean.parseBoolean(properties.getProperty("enableconsole", "true")); this.enableDebugConsole = Boolean.parseBoolean(properties.getProperty("enabledebugconsole", "false")); this.javaPath = properties.getProperty("javapath", Utils.getJavaHome()); } catch (FileNotFoundException e) { this.console.logStackTrace(e); } catch (IOException e) { this.console.logStackTrace(e); } }
From source file:com.mycompany.zad1.MainWindow.java
private void laplasjanButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_laplasjanButtonActionPerformed String[] buttonsLabels = { "Lap1", "Lap2", "Lap3", "file" }; Laplacea laplacea = new Laplacea(); boolean flag = false; int result = JOptionPane.showOptionDialog(null, "Choose Mask", "Choose laplasjan mask", JOptionPane.INFORMATION_MESSAGE, 0, null, buttonsLabels, buttonsLabels[0]); switch (result) { case 0://from w w w. j av a 2s. co m System.out.println("1"); imageBuff = laplacea.computeImage(imageBuff, result); flag = true; break; case 1: System.out.println("2"); imageBuff = laplacea.computeImage(imageBuff, result); flag = true; break; case 2: System.out.println("3"); imageBuff = laplacea.computeImage(imageBuff, result); flag = true; break; case 3: int[][] mask = loadMask(); if (mask != null) { imageBuff = laplacea.computeImage(imageOrginal, mask); System.out.println("Robi"); flag = true; } break; } if (flag) imageMoiffayLabel.setIcon(new ImageIcon(imageBuff.getImage())); }
From source file:net.sf.firemox.DeckBuilder.java
/** * check if the current deck has been modified since it has been saved. If the * current deck has been modified, we ask to the user if he want to save it * before loading another.//from w w w . j a v a 2s. com * * @return true if the user has chosen to save the deck before continuing and * if the save has success. False otherwise */ private boolean verifyModification() { if (!modifiedSinceSave) { // no modification since the last save return true; } // ask to the user if we save the current deck before loading another Object[] options = { "Ok", "No", "Cancel" }; switch (JOptionPane.showOptionDialog(form, "Current deck has been modified, save it before loading another?", "Save changes", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, options, null)) { case 0: // YES part return saveCurrentDeck(); case 1: // NO part return true; default: // CANCEL part return false; } }
From source file:edu.ku.brc.specify.config.init.secwiz.DatabasePanel.java
/** * Check the engine and charset.//from ww w . ja va2 s . c om * @param props the props * @return true if it exists */ protected boolean checkEngineCharSet(final Properties props) { final String databaseName = props.getProperty(DBNAME); DBMSUserMgr mgr = null; try { String itUsername = props.getProperty(DBUSERNAME); String itPassword = props.getProperty(DBPWD); String hostName = props.getProperty(HOSTNAME); if (!DBConnection.getInstance().isEmbedded()) { mgr = DBMSUserMgr.getInstance(); if (mgr.connectToDBMS(itUsername, itPassword, hostName)) { if (!mgr.verifyEngineAndCharSet(databaseName)) { String errMsg = mgr.getErrorMsg(); if (errMsg != null) { Object[] options = { getResourceString("CLOSE") }; JOptionPane.showOptionDialog(getTopWindow(), errMsg, getResourceString("DEL_CUR_DB_TITLE"), JOptionPane.OK_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); } return false; } return true; } } else { return true; } } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(SpecifyDBSecurityWizard.class, ex); } finally { if (mgr != null) { mgr.close(); } } return false; }
From source file:org.fhaes.fhsamplesize.view.FHSampleSize.java
/** * Open a JFileChooser and return the file that the user specified for saving. Takes a parameter that specifies the type of file. Either * TAB or PNG./*from w w w. j ava 2 s . c o m*/ * * @return */ private File getFileFromSaveDialog(String fileTypeToSave) { String lastVisitedFolder = App.prefs.getPref(PrefKey.PREF_LAST_EXPORT_FOLDER, null); JFileChooser fc = new JFileChooser(lastVisitedFolder); File outputFile; if (fileTypeToSave == "TAB") { TABFilter filterTAB = new TABFilter(); fc.addChoosableFileFilter(filterTAB); fc.setFileFilter(filterTAB); fc.setDialogTitle("Export table as text file..."); } else if (fileTypeToSave == "PDF") { PDFFilter filterPDF = new PDFFilter(); fc.addChoosableFileFilter(filterPDF); fc.setFileFilter(filterPDF); fc.setDialogTitle("Export chart as PDF..."); } fc.setFileSelectionMode(JFileChooser.FILES_ONLY); fc.setMultiSelectionEnabled(false); int returnVal = fc.showSaveDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { outputFile = fc.getSelectedFile(); if (FileUtils.getExtension(outputFile.getAbsolutePath()) == "") { log.debug("Output file extension not set by user"); if (fc.getFileFilter().getDescription().equals(new CSVFileFilter().getDescription())) { log.debug("Adding csv extension to output file name"); outputFile = new File(outputFile.getAbsolutePath() + ".csv"); } else if (fc.getFileFilter().getDescription().equals(new PDFFilter().getDescription())) { log.debug("Adding pdf extension to output file name"); outputFile = new File(outputFile.getAbsolutePath() + ".pdf"); } } else { log.debug("Output file extension set my user to '" + FileUtils.getExtension(outputFile.getAbsolutePath()) + "'"); } App.prefs.setPref(PrefKey.PREF_LAST_EXPORT_FOLDER, outputFile.getAbsolutePath()); } else { return null; } if (outputFile.exists()) { Object[] options = { "Overwrite", "No", "Cancel" }; // notes about parameters: null (don't use custom icon), options (the titles of buttons), options[0] (default button title) int response = JOptionPane.showOptionDialog(App.mainFrame, "The file '" + outputFile.getName() + "' already exists. Are you sure you want to overwrite?", "Confirm", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (response != JOptionPane.YES_OPTION) return null; } return outputFile; }
From source file:corelyzer.ui.CorelyzerGLCanvas.java
private void handleClastMouseReleased(final MouseEvent e) { if (selectedTrackSection != -1) { Point releasePos = e.getPoint(); float[] releaseScenePos = { 0.0f, 0.0f }; float[] releaseAbsPos = { 0.0f, 0.0f }; convertMousePointToSceneSpace(releasePos, releaseScenePos); if (!SceneGraph.getDepthOrientation()) { float t = scenePos[0]; scenePos[0] = scenePos[1];//from w w w .j a v a 2 s .c om scenePos[1] = -t; } SceneGraph.addClastPoint2(scenePos[0], scenePos[1]); convertScenePointToAbsolute(scenePos, releaseAbsPos); CorelyzerApp.getApp().getToolFrame().setClastLowerRight(releaseAbsPos); float[] clastUpperLeft = CorelyzerApp.getApp().getToolFrame().getClastUpperLeft(); String trackname = CorelyzerApp.getApp().getTrackListModel().getElementAt(selectedTrackIndex) .toString(); String secname = CorelyzerApp.getApp().getSectionListModel().getElementAt(selectedTrackSectionIndex) .toString(); String sessionname = CoreGraph.getInstance().getCurrentSession().getName(); // Different kinds of annotations AnnotationTypeDirectory dir = AnnotationTypeDirectory.getLocalAnnotationTypeDirectory(); if (dir == null) { System.out.println("Null AnnotationTypeDirectory abort."); return; } Enumeration<String> keys = dir.keys(); Vector<String> annotationOptions = new Vector<String>(); annotationOptions.add("Cancel"); while (keys.hasMoreElements()) { annotationOptions.add(keys.nextElement()); } Object[] options = annotationOptions.toArray(); int sel = JOptionPane.showOptionDialog(getPopupParent(), "Which kind of Annotation?", "Annotation Form Selector", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (sel < 0) { return; } try { this.handleAnnotationEvent(options[sel].toString(), sessionname, trackname, secname, clastUpperLeft, releaseAbsPos); } catch (ClassNotFoundException e1) { e1.printStackTrace(); } catch (IllegalAccessException e1) { e1.printStackTrace(); } catch (InstantiationException e1) { e1.printStackTrace(); } } }
From source file:com.atlauncher.data.Settings.java
private void checkForLauncherUpdate() { LogManager.debug("Checking for launcher update"); if (launcherHasUpdate()) { if (!App.wasUpdated) { downloadUpdate(); // Update the Launcher } else {//from w w w . jav a2 s. c om String[] options = { "Ok" }; JOptionPane.showOptionDialog(App.settings.getParent(), HTMLUtils.centerParagraph("Update failed. " + "Please click Ok to close " + "the launcher and open up the downloads " + "page.<br/><br/>Download " + "the update and replace the old ATLauncher file."), "Update Failed!", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE, null, options, options[0]); Utils.openBrowser("http://www.atlauncher.com/downloads/"); System.exit(0); } } else if (Constants.VERSION.isBeta() && launcherHasBetaUpdate()) { downloadBetaUpdate(); } LogManager.debug("Finished checking for launcher update"); }
From source file:edu.ku.brc.specify.tasks.subpane.security.SecurityAdminPane.java
/** * @param objWrapper//from w ww . j a v a 2s . c om * @param groupObjWrapper * @param selectedObjTitle */ /*private void showInfoPanel(final DataModelObjBaseWrapper objWrapperArg, final DataModelObjBaseWrapper userObjWrapperArg, final DataModelObjBaseWrapper groupObjWrapperArg, final DataModelObjBaseWrapper collectionWrapperArg, final String selectedObjTitle) { String className = objWrapperArg.getType(); CardLayout cardLayout = (CardLayout)(infoCards.getLayout()); // This displays the panel that says they have all permissions DataModelObjBaseWrapper wrpr = groupObjWrapperArg != null ? groupObjWrapperArg : objWrapperArg; if (wrpr != null) { Object dataObj = wrpr.getDataObj(); if (dataObj instanceof SpPrincipal && ((SpPrincipal)dataObj).getGroupSubClass().equals(AdminPrincipal.class.getName())) { cardLayout.show(infoCards, AdminPrincipal.class.getCanonicalName()); return; } } if (currentEditorPanel != null && currentEditorPanel.hasChanged()) { String[] optionLabels = new String[] {getResourceString("SaveChangesBtn"), getResourceString("DiscardChangesBtn"), getResourceString("CANCEL")}; int rv = JOptionPane.showOptionDialog(UIRegistry.getTopWindow(), UIRegistry.getLocalizedMessage("SaveChanges", currentTitle), getResourceString("SaveChangesTitle"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, optionLabels, optionLabels[0]); if (rv == JOptionPane.YES_OPTION) { doSave(true); } } currentTitle = selectedObjTitle; // show info panel that corresponds to the type of object selected AdminInfoSubPanelWrapper panelWrapper = infoSubPanels.get(className); currentEditorPanel = editorPanels.get(className); if (currentEditorPanel != null) { currentEditorPanel.setHasChanged(false); } // fill form with object data if (panelWrapper != null) { currentDisplayPanel = panelWrapper; if (currentDisplayPanel.setData(objWrapperArg, userObjWrapperArg, groupObjWrapperArg, collectionWrapperArg, nodesDivision) && currentEditorPanel != null) { currentEditorPanel.setHasChanged(true); } cardLayout.show(infoCards, className); } objWrapper = objWrapperArg; groupObjWrapper = groupObjWrapperArg; collectionObjWrapper = collectionWrapperArg; }*/ private void showInfoPanel(final DataModelObjBaseWrapper objWrapperArg, final DataModelObjBaseWrapper secondObjWrapperArg, final DataModelObjBaseWrapper collectionWrapperArg, final String selectedObjTitle) { String className = objWrapperArg.getType(); CardLayout cardLayout = (CardLayout) (infoCards.getLayout()); // This displays the panel that says they have all permissions DataModelObjBaseWrapper wrpr = secondObjWrapperArg != null ? secondObjWrapperArg : objWrapperArg; if (wrpr != null) { Object dataObj = wrpr.getDataObj(); if (dataObj instanceof SpPrincipal && ((SpPrincipal) dataObj).getGroupSubClass().equals(AdminPrincipal.class.getName())) { cardLayout.show(infoCards, AdminPrincipal.class.getCanonicalName()); return; } } if (currentEditorPanel != null && currentEditorPanel.hasChanged()) { String[] optionLabels = new String[] { getResourceString("SaveChangesBtn"), getResourceString("DiscardChangesBtn"), getResourceString("CANCEL") }; int rv = JOptionPane.showOptionDialog(UIRegistry.getTopWindow(), UIRegistry.getLocalizedMessage("SaveChanges", currentTitle), getResourceString("SaveChangesTitle"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, optionLabels, optionLabels[0]); if (rv == JOptionPane.YES_OPTION) { doSave(true); } } currentTitle = selectedObjTitle; // show info panel that corresponds to the type of object selected AdminInfoSubPanelWrapper panelWrapper = infoSubPanels.get(className); currentEditorPanel = editorPanels.get(className); if (currentEditorPanel != null) { currentEditorPanel.setHasChanged(false); } // fill form with object data if (panelWrapper != null) { currentDisplayPanel = panelWrapper; if (currentDisplayPanel.setData(objWrapperArg, secondObjWrapperArg, collectionWrapperArg, nodesDivision) && currentEditorPanel != null) { currentEditorPanel.setHasChanged(true); } cardLayout.show(infoCards, className); } objWrapper = objWrapperArg; secondObjWrapper = secondObjWrapperArg; collectionWrapper = collectionWrapperArg; }
From source file:com.iucosoft.eavertizare.gui.MainJFrame.java
private void jButtonExportPdfActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonExportPdfActionPerformed Vector element = new Vector(); for (int i = 0; i < firmeListModel.getSize(); i++) { element.add(firmeListModel.getElementAt(i)); }//from ww w. ja va 2s . co m final JComboBox<String> combo = new JComboBox<>(element); String[] options = { "OK", "Cancel" }; String title = "Selctati firma!"; int selection = JOptionPane.showOptionDialog(null, combo, title, JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, element.get(0)); try { if (options[selection].equals("OK")) { Object firmaSelectata = combo.getSelectedItem(); if (firmaSelectata.equals("All firms")) { clientiTableModel.refreshModel(); } else { clientiTableModel.refreshModel((String) firmaSelectata); } Export.toPdf(this, jTableClients, (String) firmaSelectata); clientiTableModel.refreshModel(); } } catch (Exception e) { } }