List of usage examples for javax.swing JOptionPane NO_OPTION
int NO_OPTION
To view the source code for javax.swing JOptionPane NO_OPTION.
Click Source Link
From source file:tufts.vue.action.ActionUtil.java
public static File selectFile(String title, final String fileType) { File picked = null;/*from w ww.j a v a2 s . c o m*/ saveChooser = VueFileChooser.getVueFileChooser(); saveChooser.setDialogTitle(title); saveChooser.setAcceptAllFileFilterUsed(false); //chooser.set if (fileType != null && !fileType.equals("export")) saveChooser.setFileFilter(new VueFileFilter(fileType)); else if (fileType != null && fileType.equals("export")) { saveChooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.JPEG_DESCRIPTION)); saveChooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.PNG_DESCRIPTION)); saveChooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.SVG_DESCRIPTION)); saveChooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.IMS_DESCRIPTION)); saveChooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.IMAGEMAP_DESCRIPTION)); // chooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.ZIP_DESCRIPTION)); } else { VueFileFilter defaultFilter = new VueFileFilter(VueFileFilter.VUE_DESCRIPTION); saveChooser.addChoosableFileFilter(defaultFilter); saveChooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.VPK_DESCRIPTION)); //SIMILE chooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.SIMILE_DESCRIPTION)); saveChooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.IMAGEMAP_DESCRIPTION)); saveChooser.addChoosableFileFilter(new VueFileFilter("PDF")); saveChooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.JPEG_DESCRIPTION)); saveChooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.PNG_DESCRIPTION)); saveChooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.SVG_DESCRIPTION)); //chooser.addChoosableFileFilter(new VueFileFilter("html")); saveChooser.addChoosableFileFilter(new VueFileFilter("RDF")); saveChooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.IMS_DESCRIPTION)); // chooser.addChoosableFileFilter(new VueFileFilter(VueFileFilter.ZIP_DESCRIPTION)); //chooser.addChoosableFileFilter(new VueFileFilter("HTML Outline", "htm")); saveChooser.setFileFilter(defaultFilter); } saveChooser.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent arg0) { if (arg0.getPropertyName() == VueFileChooser.FILE_FILTER_CHANGED_PROPERTY) { adjustExtension(); } } }); adjustExtension(); int option = saveChooser.showSaveDialog(VUE.getDialogParentAsFrame());//, VueResources.getString("dialog.save.title")); if (option == VueFileChooser.APPROVE_OPTION) { picked = saveChooser.getSelectedFile(); String fileName = picked.getAbsolutePath(); /** * 2009-10-16 There was a bug in here that sliced up the filename, I think removing this block * of code should fix the issue. If you had a name like Object.Generic-Tufts, VUE would get * all confused and put files in the wrong directory or make a file called Object the filename * slicing seemed unnecessary. -MK * */ String extension = ((VueFileFilter) saveChooser.getFileFilter()).getExtensions()[0]; //if it isn't a file name with the right extension if (!picked.getName().endsWith("." + extension)) { fileName += "." + extension; picked = new File(fileName); } if (picked.exists()) { int n = VueUtil.confirm(null, VueResources.getString("replaceFile.text") + " \'" + picked.getName() + "\'", VueResources.getString("replaceFile.title"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (n == JOptionPane.NO_OPTION) { picked = null; saveChooser.showDialog(VUE.getDialogParentAsFrame(), VueResources.getString("dialog.save.title")); } } if (picked != null) VueUtil.setCurrentDirectoryPath(picked.getParent()); } return picked; }
From source file:tvbrowser.core.Settings.java
/** * Reads the settings from settings file. If there is no settings file, * default settings are used.//w w w .j a v a 2 s .c o m */ public static void loadSettings() { String oldDirectoryName = System.getProperty("user.home", "") + File.separator + ".tvbrowser"; String newDirectoryName = getUserSettingsDirName(); File settingsFile = new File(newDirectoryName, SETTINGS_FILE); File firstSettingsBackupFile = new File(getUserSettingsDirName(), SETTINGS_FILE + "_backup1"); File secondSettingsBackupFile = new File(getUserSettingsDirName(), SETTINGS_FILE + "_backup2"); if (settingsFile.exists() || firstSettingsBackupFile.exists() || secondSettingsBackupFile.exists()) { try { mProp.readFromFile(settingsFile); if (((mProp.getProperty("subscribedchannels") == null || mProp.getProperty("subscribedchannels").trim().length() < 1) && (mProp.getProperty("channelsWereConfigured") != null && mProp.getProperty("channelsWereConfigured").equals("true"))) && (firstSettingsBackupFile.isFile() || secondSettingsBackupFile.isFile())) { throw new IOException(); } else { mLog.info("Using settings from file " + settingsFile.getAbsolutePath()); } } catch (IOException evt) { if (firstSettingsBackupFile.isFile() || secondSettingsBackupFile.isFile()) { Localizer localizer = Localizer.getLocalizerFor(Settings.class); if (JOptionPane.showConfirmDialog(null, localizer.msg("settingBroken", "Settings file broken.\nWould you like to load the backup file?\n\n(If you select No, the\ndefault settings are used)"), Localizer.getLocalization(Localizer.I18N_ERROR), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION) { boolean loadSecondBackup = !firstSettingsBackupFile.isFile(); if (firstSettingsBackupFile.isFile()) { try { mProp.readFromFile(firstSettingsBackupFile); if ((mProp.getProperty("subscribedchannels") == null || mProp.getProperty("subscribedchannels").trim().length() < 1) && secondSettingsBackupFile.isFile()) { loadSecondBackup = true; } else { mLog.info("Using settings from file " + firstSettingsBackupFile.getAbsolutePath()); loadSecondBackup = false; } } catch (Exception e) { loadSecondBackup = true; } } if (loadSecondBackup && secondSettingsBackupFile.isFile()) { try { mProp.readFromFile(secondSettingsBackupFile); mLog.info("Using settings from file " + secondSettingsBackupFile.getAbsolutePath()); loadSecondBackup = false; } catch (Exception e) { loadSecondBackup = true; } } if (loadSecondBackup) { mLog.info("Could not read settings - using default user settings"); } else { try { loadWindowSettings(); storeSettings(true); } catch (Exception e) { } } } } else { mLog.info("Could not read settings - using default user settings"); } } } /* * If the settings file doesn't exist, we try to import the settings created * by a previous version of TV-Browser */ else if (!oldDirectoryName.equals(newDirectoryName)) { File oldDir = null; File testFile = null; int countValue = 1; String firstDir = System.getProperty("user.home") + "/TV-Browser"; if (Launch.isOsWindowsNtBranch()) { countValue = 3; } if (OperatingSystem.isWindows()) { File test = new File(System.getenv("appdata"), "TV-Browser"); if (test.isDirectory()) { firstDir = test.getAbsolutePath(); } } String[] directories = { getUserDirectoryName(), firstDir, System.getProperty("user.home") + "/TV-Browser", System.getProperty("user.home") + "/Library/Preferences/TV-Browser", System.getProperty("user.home") + "/.tvbrowser" }; for (int j = 0; j < (TVBrowser.isTransportable() ? directories.length : countValue); j++) { String[] allVersions = TVBrowser.getAllVersionStrings(); for (int i = (j == 0 ? 1 : 0); i < allVersions.length; i++) { testFile = new File(directories[j] + File.separator + allVersions[i], SETTINGS_FILE); if (testFile.isFile()) { oldDir = new File(directories[j], allVersions[i]); break; } } if (oldDir == null) { testFile = new File(directories[j], SETTINGS_FILE); if (testFile.isFile()) { oldDir = new File(directories[j]); } else { testFile = new File(oldDirectoryName, SETTINGS_FILE); if (testFile.isFile()) { oldDir = new File(oldDirectoryName); } } } if (oldDir != null) { break; } } if (oldDir != null && oldDir.isDirectory() && oldDir.exists() && TVBrowser.isTransportable() && !oldDir.getAbsolutePath().startsWith(new File("settings").getAbsolutePath())) { try { UIManager.setLookAndFeel(getDefaultLookAndFeelClassName()); } catch (Exception e) { /*ignore*/} String[] options = { MainFrame.mLocalizer.msg("import", "Import settings"), MainFrame.mLocalizer.msg("configureNew", "Create new configuration") }; String title = MainFrame.mLocalizer.msg("importInfoTitle", "Import settings?"); String msg = MainFrame.mLocalizer.msg("importInfoMsg", "TV-Browser has found settings for import.\nShould the settings be imported now?"); if (JOptionPane.showOptionDialog(null, msg, title, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]) == JOptionPane.NO_OPTION) { oldDir = null; } } if (oldDir != null && oldDir.isDirectory() && oldDir.exists()) { startImportWaitingDlg(); mLog.info("Try to load settings from a previous version of TV-Browser: " + oldDir); final File newDir = new File(getUserSettingsDirName()); File oldTvDataDir = null; final Properties prop = new Properties(); try { StreamUtilities.inputStream(testFile, new InputStreamProcessor() { public void process(InputStream input) throws IOException { prop.load(input); } }); } catch (Exception e) { } String versionString = prop.getProperty("version", null); Version testVersion = null; if (versionString != null) { try { int asInt = Integer.parseInt(versionString); int major = asInt / 100; int minor = asInt % 100; testVersion = new Version(major, minor); } catch (NumberFormatException exc) { // Ignore } } String temp = prop.getProperty("dir.tvdata", null); boolean versionTest = !TVBrowser.isTransportable() && Launch.isOsWindowsNtBranch() && testVersion != null && testVersion.compareTo(new Version(3, 0, true)) < 0 && (temp == null || temp.replace("/", "\\") .equals(System.getProperty("user.home") + "\\TV-Browser\\tvdata")); if ((TVBrowser.isTransportable() || versionTest) && !(new File(getUserDirectoryName(), "tvdata").isDirectory())) { try { if (temp != null) { oldTvDataDir = new File(temp); } else if (new File(oldDir, "tvdata").isDirectory()) { oldTvDataDir = new File(oldDir, "tvdata"); } else if (new File(oldDir.getParent(), "tvdata").isDirectory()) { oldTvDataDir = new File(oldDir.getParent(), "tvdata"); } } catch (Exception e) { } } if (newDir.mkdirs()) { try { IOUtilities.copy(oldDir.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return !name.equalsIgnoreCase("tvdata") && !name.equals(newDir.getName()) && !name.equalsIgnoreCase("backup") && !name.equalsIgnoreCase("lang"); } }), newDir); mShowSettingsCopyWaiting = false; mLog.info("settings from previous version copied successfully"); File newSettingsFile = new File(newDir, SETTINGS_FILE); mProp.readFromFile(newSettingsFile); mLog.info("settings from previous version read successfully"); /* * This is the .tvbrowser dir, if there are settings form version * 1.0 change the name to start with java. */ if (oldDirectoryName.equals(oldDir.getAbsolutePath())) { File[] settings = newDir.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return (name.toLowerCase().endsWith(".prop") && name.toLowerCase().indexOf("settings") == -1) || (name.toLowerCase().endsWith(".dat") && name.toLowerCase().indexOf("tv-data-inventory") == -1); } }); boolean version1 = false; if (settings != null) { for (int i = 0; i < settings.length; i++) { String name = "java." + settings[i].getName(); if (!settings[i].getName().toLowerCase().startsWith("java.")) { version1 = true; settings[i].renameTo(new File(settings[i].getParent(), name)); } } } if (version1 && !(new File(oldDirectoryName, newDir.getName())).isDirectory()) { oldDir.renameTo(new File( System.getProperty("user.home", "") + File.separator + "tvbrowser_BACKUP")); } } /* * Test if and copy TV data for the portable version. */ if (oldTvDataDir != null && oldTvDataDir.isDirectory()) { final File targetDir = new File(getUserDirectoryName(), "tvdata"); if (!oldTvDataDir.equals(targetDir)) { targetDir.mkdirs(); final CopyWaitingDlg waiting = new CopyWaitingDlg(new JFrame(), versionTest ? CopyWaitingDlg.APPDATA_MSG : CopyWaitingDlg.IMPORT_MSG); mShowWaiting = true; final File srcDir = oldTvDataDir; Thread copyDataThread = new Thread("Copy TV data directory") { public void run() { try { IOUtilities.copy(srcDir.listFiles(), targetDir, true); } catch (Exception e) { } mShowWaiting = false; waiting.setVisible(false); } }; copyDataThread.start(); waiting.setVisible(mShowWaiting); } } /* * Test if a settings file exist in the user directory, move the * settings to backup. */ if ((new File(getUserDirectoryName(), SETTINGS_FILE)).isFile()) { final File backupDir = new File(getUserDirectoryName(), "BACKUP"); if (backupDir.mkdirs()) { mLog.info("moving the settings of old settings dir to backup"); File[] files = oldDir.listFiles(new FileFilter() { public boolean accept(File pathname) { return pathname.compareTo(newDir) != 0 && pathname.getName().compareToIgnoreCase("tvdata") != 0 && pathname.compareTo(backupDir) != 0; } }); if (files != null) { for (File file : files) { file.renameTo(new File(backupDir, file.getName())); } } } } } catch (IOException e) { mLog.log(Level.WARNING, "Could not import user settings from '" + oldDir.getAbsolutePath() + "' to '" + newDir.getAbsolutePath() + "'", e); } } else { mLog.info("Could not create directory '" + newDir.getAbsolutePath() + "' - using default user settings"); } } else { mLog.info("No previous version of TV-Browser found - using default user settings"); } } mShowSettingsCopyWaiting = false; File settingsDir = new File(newDirectoryName); if (!settingsDir.exists()) { mLog.info("Creating " + newDirectoryName); settingsDir.mkdir(); } loadWindowSettings(); }
From source file:uk.chromis.pos.config.JPanelConfiguration.java
/** * * @return//from w ww .j a v a 2 s . c om */ @Override public boolean deactivate() { boolean haschanged = false; for (PanelConfig c : m_panelconfig) { if (c.hasChanged()) { haschanged = true; } } if (haschanged) { int res = JOptionPane.showConfirmDialog(this, AppLocal.getIntString("message.wannasave"), AppLocal.getIntString("title.editor"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (res == JOptionPane.YES_OPTION) { saveProperties(); return true; } else { return res == JOptionPane.NO_OPTION; } } else { return true; } }
From source file:uk.co.modularaudio.componentdesigner.mainframe.actions.ExitAction.java
@Override public void actionPerformed(final ActionEvent e) { if (fc.isRendering()) { fc.toggleRendering();//from w ww . j av a 2 s. c o m } log.debug("ExitAction perform called."); int optionPaneResult = mainFrameActions.rackNotDirtyOrUserConfirmed(); if (optionPaneResult == JOptionPane.YES_OPTION) { // Need to save it - call the save saveFileAction.actionPerformed(e); // Simulate the cancel in the save action if the rack is still dirty. optionPaneResult = (fc.isRackDirty() ? JOptionPane.CANCEL_OPTION : JOptionPane.NO_OPTION); } if (optionPaneResult == JOptionPane.NO_OPTION) { for (final ExitSignalReceiver esr : exitSignalReceivers) { esr.signalPreExit(); } // Stop the engine if (fc.isAudioEngineRunning()) { fc.stopAudioEngine(); } // Give any components in the graph a chance to cleanup first try { fc.ensureRenderingStoppedBeforeExit(); } catch (final Exception e1) { final String msg = "Exception caught during destruction before exit: " + e1.toString(); log.error(msg, e1); } log.debug("Will signal exit"); for (final ExitSignalReceiver esr : exitSignalReceivers) { esr.signalPostExit(); } } }
From source file:uk.co.modularaudio.componentdesigner.mainframe.actions.NewFileAction.java
@Override public void actionPerformed(final ActionEvent e) { log.debug("NewFileAction called."); int dirtyCheckVal = mainFrameActions.rackNotDirtyOrUserConfirmed(); if (dirtyCheckVal == JOptionPane.YES_OPTION) { // Need to save it - call the save saveFileAction.actionPerformed(e); // Simulate the cancel in the save action if the rack is still dirty. dirtyCheckVal = (fc.isRackDirty() ? JOptionPane.CANCEL_OPTION : JOptionPane.NO_OPTION); }//from w ww . java2 s . c o m // We don't check for cancel, as it will just fall through if (dirtyCheckVal == JOptionPane.NO_OPTION) { if (fc.isRendering()) { fc.toggleRendering(); } try { fc.newRack(); } catch (final Exception ex) { final String msg = "Exception caught performing new file action: " + ex.toString(); log.error(msg, ex); } } }
From source file:uk.co.modularaudio.componentdesigner.mainframe.actions.OpenFileAction.java
@Override public void actionPerformed(final ActionEvent e) { log.debug("OpenFileAction called."); try {/*from w ww .j a v a 2 s .com*/ int dirtyCheckVal = mainFrameActions.rackNotDirtyOrUserConfirmed(); if (dirtyCheckVal == JOptionPane.YES_OPTION) { // Need to save it - call the save saveFileAction.actionPerformed(e); // Simulate the cancel in the save action if the rack is still dirty. dirtyCheckVal = (fc.isRackDirty() ? JOptionPane.CANCEL_OPTION : JOptionPane.NO_OPTION); } // We don't check for cancel, as it will just fall through if (dirtyCheckVal == JOptionPane.NO_OPTION) { if (fc.isRendering()) { playStopAction.actionPerformed(e); } final JFileChooser openFileChooser = new JFileChooser(); final String patchesDir = upc.getUserPreferencesMVCController().getModel().getUserPatchesModel() .getValue(); openFileChooser.setCurrentDirectory(new File(patchesDir)); final int retVal = openFileChooser.showOpenDialog(mainFrame); if (retVal == JFileChooser.APPROVE_OPTION) { final File f = openFileChooser.getSelectedFile(); if (f != null) { if (log.isDebugEnabled()) { log.debug("Attempting to load from file " + f.getAbsolutePath()); } fc.loadRackFromFile(f.getAbsolutePath()); } } } } catch (final Exception ex) { final String msg = "Exception caught performing open file action: " + ex.toString(); log.error(msg, ex); } }
From source file:uk.co.modularaudio.componentdesigner.mainframe.MainFrameActions.java
public int rackNotDirtyOrUserConfirmed() { int retVal = JOptionPane.CANCEL_OPTION; if (fc.isRackDirty()) { // Show a dialog asking if they want to save the file retVal = JOptionPane.showConfirmDialog(mainFrame, MESSAGE_RACK_DIRT_CONFIRM_SAVE); } else {//from ww w . j a va 2 s . co m retVal = JOptionPane.NO_OPTION; } return retVal; }
From source file:us.daveread.basicquery.BasicQuery.java
/** * Open or create a SQL statement file./*from ww w . j a va 2 s . c o m*/ */ private void openSQLFile() { JFileChooser fileMenu; FileFilter defaultFileFilter = null; FileFilter preferredFileFilter = null; File chosenSQLFile; int returnVal; chosenSQLFile = null; // Save current information, including SQL Statements saveConfig(); // Allow user to choose/create new file for SQL Statements fileMenu = new JFileChooser(new File(queryFilename)); for (FileFilterDefinition filterDefinition : FileFilterDefinition.values()) { if (filterDefinition.name().startsWith("QUERY")) { final FileFilter fileFilter = new SuffixFileFilter(filterDefinition.description(), filterDefinition.acceptedSuffixes()); if (filterDefinition.isPreferredOption()) { preferredFileFilter = fileFilter; } fileMenu.addChoosableFileFilter(fileFilter); if (filterDefinition.description().equals(latestChosenQueryFileFilterDescription)) { defaultFileFilter = fileFilter; } } } if (defaultFileFilter != null) { fileMenu.setFileFilter(defaultFileFilter); } else if (latestChosenQueryFileFilterDescription != null && latestChosenQueryFileFilterDescription.startsWith("All")) { fileMenu.setFileFilter(fileMenu.getAcceptAllFileFilter()); } else if (preferredFileFilter != null) { fileMenu.setFileFilter(preferredFileFilter); } fileMenu.setSelectedFile(new File(queryFilename)); fileMenu.setDialogTitle(Resources.getString("dlgSQLFileTitle")); fileMenu.setDialogType(JFileChooser.OPEN_DIALOG); fileMenu.setFileSelectionMode(JFileChooser.FILES_ONLY); fileMenu.setMultiSelectionEnabled(false); if (fileMenu.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { chosenSQLFile = fileMenu.getSelectedFile(); // Adjust file suffix if necessary final FileFilter fileFilter = fileMenu.getFileFilter(); if (fileFilter != null && fileFilter instanceof SuffixFileFilter && !fileMenu.getFileFilter().accept(chosenSQLFile)) { chosenSQLFile = ((SuffixFileFilter) fileFilter).makeWithPrimarySuffix(chosenSQLFile); } if (!chosenSQLFile.exists()) { returnVal = JOptionPane.showConfirmDialog(this, Resources.getString("dlgNewSQLFileText", chosenSQLFile.getName()), Resources.getString("dlgNewSQLFileTitle"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (returnVal == JOptionPane.NO_OPTION) { querySelection.removeAllItems(); queryText.setText(""); QueryHistory.getInstance().clearAllQueries(); // Update GUI setPrevNextIndication(); } else if (returnVal == JOptionPane.CANCEL_OPTION) { chosenSQLFile = null; } } else { setQueryFilename(chosenSQLFile.getAbsolutePath()); querySelection.removeAllItems(); queryText.setText(""); loadCombo(querySelection, queryFilename); QueryHistory.getInstance().clearAllQueries(); // Update GUI setPrevNextIndication(); } } try { latestChosenQueryFileFilterDescription = fileMenu.getFileFilter().getDescription(); } catch (Throwable throwable) { LOGGER.warn("Unable to determine which ontology file filter was chosen", throwable); } if (chosenSQLFile != null) { setQueryFilename(chosenSQLFile.getAbsolutePath()); saveConfig(); } }
From source file:view.CertificateManagementDialog.java
private void btnRemoveCertActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoveCertActionPerformed int[] indices = jList1.getSelectedIndices(); if (indices.length != 0) { String msg = (indices.length == 1 ? Bundle.getBundle().getString("removeCert1") : Bundle.getBundle().getString("removeCert2") + " " + indices.length + " " + Bundle.getBundle().getString("removeCert3")); Object[] options = { Bundle.getBundle().getString("yes"), Bundle.getBundle().getString("no") }; int opt = JOptionPane.showOptionDialog(null, msg, "", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (opt == JOptionPane.NO_OPTION) { return; }// w w w . j av a2 s .co m final ArrayList<Certificate> toRemove = new ArrayList<>(); for (int index : indices) { toRemove.add(alTrusted.get(index)); } String password = getUserInputPassword(); if (password == null) { return; } for (Certificate cert : toRemove) { removeCertFromKeystore(cert, password); alTrusted.remove(cert); } } }
From source file:view.CertificateManagementDialog.java
private String getUserInputPassword() { JPanel panel = new JPanel(); JLabel lblInsertPassword = new JLabel(Bundle.getBundle().getString("insertKeystorePassword")); JPasswordField pf = new JPasswordField(10); panel.add(lblInsertPassword);//w ww . j ava2s. co m panel.add(pf); String[] options = new String[] { Bundle.getBundle().getString("btn.ok"), Bundle.getBundle().getString("btn.cancel") }; int option = JOptionPane.showOptionDialog(null, panel, null, JOptionPane.NO_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[1]); if (option == JOptionPane.OK_OPTION) { char[] password = pf.getPassword(); return new String(password); } return null; }