List of usage examples for javax.swing JPasswordField JPasswordField
public JPasswordField(int columns)
JPasswordField
with the specified number of columns. From source file:edu.smc.mediacommons.panels.PasswordPanel.java
public PasswordPanel() { setLayout(null);// ww w. j ava 2 s .c o m add(Utils.createLabel("Enter a Password to Test", 60, 30, 200, 20, null)); final JButton test = Utils.createButton("Test", 260, 50, 100, 20, null); add(test); final JPasswordField fieldPassword = new JPasswordField(32); fieldPassword.setBounds(60, 50, 200, 20); add(fieldPassword); final PieDataset dataset = createSampleDataset(33, 33, 33); final JFreeChart chart = createChart(dataset); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(300, 300)); chartPanel.setBounds(45, 80, 340, 250); add(chartPanel); test.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String password = new String(fieldPassword.getPassword()); if (password.isEmpty() || password == null) { JOptionPane.showMessageDialog(getParent(), "Warning! The input was blank!", "Invalid Input", JOptionPane.ERROR_MESSAGE); } else { int letterCount = 0, numberCount = 0, specialCount = 0, total = password.length(); for (char c : password.toCharArray()) { if (Character.isLetter(c)) { letterCount++; } else if (Character.isDigit(c)) { numberCount++; } else { specialCount++; } } long totalCombinations = 0; double percentLetters = 0; double percentNumbers = 0; double percentCharacters = 0; if (letterCount > 0) { totalCombinations += (factorial(26) / factorial(26 - letterCount)); percentLetters = (letterCount + 0.0 / total); } if (numberCount > 0) { totalCombinations += (factorial(10) / factorial(10 - numberCount)); percentNumbers = (numberCount + 0.0 / total); } if (specialCount > 0) { totalCombinations += (factorial(40) / factorial(40 - specialCount)); percentCharacters = (specialCount + 0.0 / total); } PieDataset dataset = createSampleDataset(percentLetters, percentNumbers, percentCharacters); JFreeChart chart = createChart(dataset); chartPanel.setChart(chart); JOptionPane.showMessageDialog(getParent(), "Total Combinations: " + totalCombinations + "\nAssuming Rate Limited, Single: " + (totalCombinations / 1000) + " seconds" + "\n\nBreakdown:\nLetters: " + percentLetters + "%\nNumbers: " + percentNumbers + "%\nCharacters: " + percentCharacters + "%"); } } }); setVisible(true); }
From source file:be.fedict.eid.tsl.Pkcs11CallbackHandler.java
private char[] getPin() { Box mainPanel = Box.createVerticalBox(); Box passwordPanel = Box.createHorizontalBox(); JLabel promptLabel = new JLabel("eID PIN:"); passwordPanel.add(promptLabel);// w w w. j a v a 2 s .co m passwordPanel.add(Box.createHorizontalStrut(5)); JPasswordField passwordField = new JPasswordField(8); passwordPanel.add(passwordField); mainPanel.add(passwordPanel); Component parentComponent = null; int result = JOptionPane.showOptionDialog(parentComponent, mainPanel, "eID PIN?", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); if (result == JOptionPane.OK_OPTION) { char[] pin = passwordField.getPassword(); return pin; } throw new RuntimeException("operation canceled."); }
From source file:components.PasswordDemo.java
public PasswordDemo(JFrame f) { //Use the default FlowLayout. controllingFrame = f;//from w w w . j a v a 2 s. c o m //Create everything. passwordField = new JPasswordField(10); passwordField.setActionCommand(OK); passwordField.addActionListener(this); JLabel label = new JLabel("Enter the password: "); label.setLabelFor(passwordField); JComponent buttonPane = createButtonPanel(); //Lay out everything. JPanel textPane = new JPanel(new FlowLayout(FlowLayout.TRAILING)); textPane.add(label); textPane.add(passwordField); add(textPane); add(buttonPane); }
From source file:components.TextSamplerDemo.java
public TextSamplerDemo() { setLayout(new BorderLayout()); //Create a regular text field. JTextField textField = new JTextField(10); textField.setActionCommand(textFieldString); textField.addActionListener(this); //Create a password field. JPasswordField passwordField = new JPasswordField(10); passwordField.setActionCommand(passwordFieldString); passwordField.addActionListener(this); //Create a formatted text field. JFormattedTextField ftf = new JFormattedTextField(java.util.Calendar.getInstance().getTime()); ftf.setActionCommand(textFieldString); ftf.addActionListener(this); //Create some labels for the fields. JLabel textFieldLabel = new JLabel(textFieldString + ": "); textFieldLabel.setLabelFor(textField); JLabel passwordFieldLabel = new JLabel(passwordFieldString + ": "); passwordFieldLabel.setLabelFor(passwordField); JLabel ftfLabel = new JLabel(ftfString + ": "); ftfLabel.setLabelFor(ftf);/*from w ww.ja v a 2 s.com*/ //Create a label to put messages during an action event. actionLabel = new JLabel("Type text in a field and press Enter."); actionLabel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); //Lay out the text controls and the labels. JPanel textControlsPane = new JPanel(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); textControlsPane.setLayout(gridbag); JLabel[] labels = { textFieldLabel, passwordFieldLabel, ftfLabel }; JTextField[] textFields = { textField, passwordField, ftf }; addLabelTextRows(labels, textFields, gridbag, textControlsPane); c.gridwidth = GridBagConstraints.REMAINDER; //last c.anchor = GridBagConstraints.WEST; c.weightx = 1.0; textControlsPane.add(actionLabel, c); textControlsPane.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("Text Fields"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); //Create a text area. JTextArea textArea = new JTextArea("This is an editable JTextArea. " + "A text area is a \"plain\" text component, " + "which means that although it can display text " + "in any font, all of the text is in the same font."); textArea.setFont(new Font("Serif", Font.ITALIC, 16)); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); JScrollPane areaScrollPane = new JScrollPane(textArea); areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); areaScrollPane.setPreferredSize(new Dimension(250, 250)); areaScrollPane.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Plain Text"), BorderFactory.createEmptyBorder(5, 5, 5, 5)), areaScrollPane.getBorder())); //Create an editor pane. JEditorPane editorPane = createEditorPane(); JScrollPane editorScrollPane = new JScrollPane(editorPane); editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); editorScrollPane.setPreferredSize(new Dimension(250, 145)); editorScrollPane.setMinimumSize(new Dimension(10, 10)); //Create a text pane. JTextPane textPane = createTextPane(); JScrollPane paneScrollPane = new JScrollPane(textPane); paneScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); paneScrollPane.setPreferredSize(new Dimension(250, 155)); paneScrollPane.setMinimumSize(new Dimension(10, 10)); //Put the editor pane and the text pane in a split pane. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, editorScrollPane, paneScrollPane); splitPane.setOneTouchExpandable(true); splitPane.setResizeWeight(0.5); JPanel rightPane = new JPanel(new GridLayout(1, 0)); rightPane.add(splitPane); rightPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Styled Text"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); //Put everything together. JPanel leftPane = new JPanel(new BorderLayout()); leftPane.add(textControlsPane, BorderLayout.PAGE_START); leftPane.add(areaScrollPane, BorderLayout.CENTER); add(leftPane, BorderLayout.LINE_START); add(rightPane, BorderLayout.LINE_END); }
From source file:br.org.acessobrasil.silvinha.vista.panels.PainelSenha.java
public PainelSenha() { lblNome = new JLabel(GERAL.USUARIO); lblPass = new JLabel(GERAL.SENHA); txtName = new JTextField(10); txtPass = new JPasswordField(10); GridBagLayout bag = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); this.setLayout(bag); lblNome.setHorizontalAlignment(JLabel.RIGHT); gbc.fill = GridBagConstraints.BOTH; gbc.weightx = 1.0;/*from ww w . j a va 2s.c om*/ gbc.insets = new Insets(2, 10, 2, 10); this.add(lblNome, gbc); txtName.setAlignmentX(SwingConstants.WEST); txtName.addActionListener(new ActivateNextTextFieldListener(txtPass)); gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.insets = new Insets(2, 0, 2, 10); this.add(txtName, gbc); lblPass.setHorizontalAlignment(JLabel.RIGHT); gbc.fill = GridBagConstraints.BOTH; gbc.gridwidth = 1; gbc.weightx = 1.0; gbc.insets = new Insets(2, 10, 2, 10); this.add(lblPass, gbc); txtPass.setAlignmentX(SwingConstants.WEST); gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.insets = new Insets(2, 0, 2, 10); this.add(txtPass, gbc); setSize(300, 130); setLocation(300, 300); // this.setBackground(corDefault); op = new JOptionPane(this, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION); // op.setBackground(corDefault); }
From source file:com.hp.alm.ali.idea.content.settings.SettingsPanel.java
public SettingsPanel(final Project prj, Color bgColor) { this.prj = prj; this.projectConf = prj.getComponent(AliProjectConfiguration.class); previewAndConnection = new JPanel(new GridBagLayout()); previewAndConnection.setOpaque(false); GridBagConstraints c2 = new GridBagConstraints(); c2.gridx = 0;/* w w w.jav a 2 s.c o m*/ c2.gridy = 1; c2.gridwidth = 2; c2.weighty = 1; c2.fill = GridBagConstraints.VERTICAL; JPanel filler = new JPanel(); filler.setOpaque(false); previewAndConnection.add(filler, c2); passwordPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); passwordPanel.setBackground(bgColor); JLabel label = new JLabel("Password"); label.setFont(label.getFont().deriveFont(Font.BOLD)); passwordPanel.add(label); final JPasswordField password = new JPasswordField(24); passwordPanel.add(password); JButton connect = new JButton("Login"); passwordPanel.add(connect); final JLabel message = new JLabel(); passwordPanel.add(message); ActionListener connectionAction = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { try { checkConnection(projectConf.getLocation(), projectConf.getDomain(), projectConf.getProject(), projectConf.getUsername(), password.getText()); } catch (AuthenticationFailed e) { message.setText(e.getMessage()); return; } projectConf.ALM_PASSWORD = password.getText(); projectConf.fireChanged(); } }; password.addActionListener(connectionAction); connect.addActionListener(connectionAction); restService = prj.getComponent(RestService.class); restService.addServerTypeListener(this); location = createTextPane(bgColor); domain = createTextPane(bgColor); project = createTextPane(bgColor); username = createTextPane(bgColor); final JPanel panel = new JPanel(new BorderLayout()); panel.setBackground(bgColor); panel.setBorder(new EmptyBorder(10, 10, 10, 10)); final JTextPane textPane = new JTextPane(); textPane.setEditorKit(new HTMLEditorKit()); textPane.setText( "<html><body>HP ALM integration can be configured on <a href=\"ide\">IDE</a> and overridden on <a href=\"project\">project</a> level.</body></html>"); textPane.setEditable(false); textPane.addHyperlinkListener(this); textPane.setBackground(bgColor); textPane.setCaret(new NonAdjustingCaret()); panel.add(textPane, BorderLayout.CENTER); JPanel content = new JPanel(new BorderLayout()); content.setBackground(bgColor); content.add(panel, BorderLayout.NORTH); content.add(previewAndConnection, BorderLayout.WEST); preview = new JPanel(new GridBagLayout()) { public Dimension getPreferredSize() { Dimension dim = super.getPreferredSize(); // make enough room for the connection status message dim.width = Math.max(dim.width, 300); return dim; } public Dimension getMinimumSize() { return getPreferredSize(); } }; connectedTo(restService.getServerTypeIfAvailable()); preview.setBackground(bgColor); final GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.gridx = 0; c.gridy = 0; c.gridwidth = 2; c.anchor = GridBagConstraints.WEST; preview.add(location, c); c.gridwidth = 1; c.gridy++; preview.add(domain, c); c.gridy++; preview.add(project, c); c.gridy++; preview.add(username, c); c.gridx++; c.gridy--; c.gridheight = 2; c.weightx = 0; c.anchor = GridBagConstraints.SOUTHEAST; final LinkLabel reload = new LinkLabel("Reload", IconLoader.getIcon("/actions/sync.png")); reload.setListener(new LinkListener() { public void linkSelected(LinkLabel linkLabel, Object o) { projectConf.fireChanged(); } }, null); preview.add(reload, c); JPanel previewNorth = new JPanel(new BorderLayout()); previewNorth.setBackground(bgColor); previewNorth.add(preview, BorderLayout.NORTH); addToGridBagPanel(0, 0, previewAndConnection, previewNorth); setBackground(bgColor); setLayout(new BorderLayout()); add(content, BorderLayout.CENTER); onChanged(); ApplicationManager.getApplication().getComponent(AliConfiguration.class).addListener(this); projectConf.addListener(this); }
From source file:TextSamplerDemo.java
public TextSamplerDemo() { setLayout(new BorderLayout()); //Create a regular text field. JTextField textField = new JTextField(10); textField.setActionCommand(textFieldString); textField.addActionListener(this); //Create a password field. JPasswordField passwordField = new JPasswordField(10); passwordField.setActionCommand(passwordFieldString); passwordField.addActionListener(this); //Create a formatted text field. JFormattedTextField ftf = new JFormattedTextField(java.util.Calendar.getInstance().getTime()); ftf.setActionCommand(textFieldString); ftf.addActionListener(this); //Create some labels for the fields. JLabel textFieldLabel = new JLabel(textFieldString + ": "); textFieldLabel.setLabelFor(textField); JLabel passwordFieldLabel = new JLabel(passwordFieldString + ": "); passwordFieldLabel.setLabelFor(passwordField); JLabel ftfLabel = new JLabel(ftfString + ": "); ftfLabel.setLabelFor(ftf);// www . ja v a2s.c om //Create a label to put messages during an action event. actionLabel = new JLabel("Type text and then Enter in a field."); actionLabel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); //Lay out the text controls and the labels. JPanel textControlsPane = new JPanel(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); textControlsPane.setLayout(gridbag); JLabel[] labels = { textFieldLabel, passwordFieldLabel, ftfLabel }; JTextField[] textFields = { textField, passwordField, ftf }; addLabelTextRows(labels, textFields, gridbag, textControlsPane); c.gridwidth = GridBagConstraints.REMAINDER; //last c.anchor = GridBagConstraints.WEST; c.weightx = 1.0; textControlsPane.add(actionLabel, c); textControlsPane.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("Text Fields"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); //Create a text area. JTextArea textArea = new JTextArea("This is an editable JTextArea. " + "A text area is a \"plain\" text component, " + "which means that although it can display text " + "in any font, all of the text is in the same font."); textArea.setFont(new Font("Serif", Font.ITALIC, 16)); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); JScrollPane areaScrollPane = new JScrollPane(textArea); areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); areaScrollPane.setPreferredSize(new Dimension(250, 250)); areaScrollPane.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Plain Text"), BorderFactory.createEmptyBorder(5, 5, 5, 5)), areaScrollPane.getBorder())); //Create an editor pane. JEditorPane editorPane = createEditorPane(); JScrollPane editorScrollPane = new JScrollPane(editorPane); editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); editorScrollPane.setPreferredSize(new Dimension(250, 145)); editorScrollPane.setMinimumSize(new Dimension(10, 10)); //Create a text pane. JTextPane textPane = createTextPane(); JScrollPane paneScrollPane = new JScrollPane(textPane); paneScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); paneScrollPane.setPreferredSize(new Dimension(250, 155)); paneScrollPane.setMinimumSize(new Dimension(10, 10)); //Put the editor pane and the text pane in a split pane. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, editorScrollPane, paneScrollPane); splitPane.setOneTouchExpandable(true); splitPane.setResizeWeight(0.5); JPanel rightPane = new JPanel(new GridLayout(1, 0)); rightPane.add(splitPane); rightPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Styled Text"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); //Put everything together. JPanel leftPane = new JPanel(new BorderLayout()); leftPane.add(textControlsPane, BorderLayout.PAGE_START); leftPane.add(areaScrollPane, BorderLayout.CENTER); add(leftPane, BorderLayout.LINE_START); add(rightPane, BorderLayout.LINE_END); }
From source file:dbseer.gui.panel.DBSeerMiddlewarePanel.java
private void initializeGUI() { this.setLayout(new MigLayout()); JLabel ipAddressLabel = new JLabel("IP Address:"); JLabel portLabel = new JLabel("Port:"); JLabel idLabel = new JLabel("ID:"); JLabel passwordLabel = new JLabel("Password:"); ipField = new JTextField(20); DecimalFormat portFormatter = new DecimalFormat(); portFormatter.setMaximumFractionDigits(0); portFormatter.setMaximumIntegerDigits(5); portFormatter.setMinimumIntegerDigits(1); portFormatter.setDecimalSeparatorAlwaysShown(false); portFormatter.setGroupingUsed(false); portField = new JFormattedTextField(portFormatter); portField.setColumns(6);//from w ww. ja v a2 s. com portField.setText("3555"); // default port. idField = new JTextField(20); passwordField = new JPasswordField(20); logInOutButton = new JButton("Login"); logInOutButton.addActionListener(this); startMonitoringButton = new JButton("Start Monitoring"); startMonitoringButton.addActionListener(this); stopMonitoringButton = new JButton("Stop Monitoring"); stopMonitoringButton.addActionListener(this); startMonitoringButton.setEnabled(true); stopMonitoringButton.setEnabled(false); ipField.setText(DBSeerGUI.userSettings.getLastMiddlewareIP()); portField.setText(String.valueOf(DBSeerGUI.userSettings.getLastMiddlewarePort())); idField.setText(DBSeerGUI.userSettings.getLastMiddlewareID()); NumberFormatter formatter = new NumberFormatter(NumberFormat.getIntegerInstance()); formatter.setMinimum(1); formatter.setMaximum(120); formatter.setAllowsInvalid(false); refreshRateLabel = new JLabel("Monitoring Refresh Rate:"); refreshRateField = new JFormattedTextField(formatter); JLabel refreshRateRangeLabel = new JLabel("(1~120 sec)"); refreshRateField.setText("1"); applyRefreshRateButton = new JButton("Apply"); applyRefreshRateButton.addActionListener(this); this.add(ipAddressLabel, "cell 0 0 2 1, split 4"); this.add(ipField); this.add(portLabel); this.add(portField); this.add(idLabel, "cell 0 2"); this.add(idField, "cell 1 2"); this.add(passwordLabel, "cell 0 3"); this.add(passwordField, "cell 1 3"); this.add(refreshRateLabel, "cell 0 4"); this.add(refreshRateField, "cell 1 4, growx, split 3"); this.add(refreshRateRangeLabel); this.add(applyRefreshRateButton, "growx, wrap"); // this.add(logInOutButton, "cell 0 2 2 1, growx, split 3"); this.add(startMonitoringButton); this.add(stopMonitoringButton); }
From source file:DataExchangeTest.java
public PasswordChooser() { setLayout(new BorderLayout()); // construct a panel with user name and password fields JPanel panel = new JPanel(); panel.setLayout(new GridLayout(2, 2)); panel.add(new JLabel("User name:")); panel.add(username = new JTextField("")); panel.add(new JLabel("Password:")); panel.add(password = new JPasswordField("")); add(panel, BorderLayout.CENTER); // create Ok and Cancel buttons that terminate the dialog okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { ok = true;/*from www.j av a 2 s . com*/ dialog.setVisible(false); } }); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { dialog.setVisible(false); } }); // add buttons to southern border JPanel buttonPanel = new JPanel(); buttonPanel.add(okButton); buttonPanel.add(cancelButton); add(buttonPanel, BorderLayout.SOUTH); }
From source file:com._17od.upm.gui.DatabaseActions.java
/** * This method asks the user for the name of a new database and then creates * it. If the file already exists then the user is asked if they'd like to * overwrite it.//from ww w .j a v a 2 s.co m * @throws CryptoException * @throws IOException */ public void newDatabase() throws IOException, CryptoException { File newDatabaseFile = getSaveAsFile(Translator.translate("newPasswordDatabase")); if (newDatabaseFile == null) { return; } final JPasswordField masterPassword = new JPasswordField(""); boolean passwordsMatch = false; do { //Get a new master password for this database from the user JPasswordField confirmedMasterPassword = new JPasswordField(""); JOptionPane pane = new JOptionPane( new Object[] { Translator.translate("enterMasterPassword"), masterPassword, Translator.translate("confirmation"), confirmedMasterPassword }, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION); JDialog dialog = pane.createDialog(mainWindow, Translator.translate("masterPassword")); dialog.addWindowFocusListener(new WindowAdapter() { public void windowGainedFocus(WindowEvent e) { masterPassword.requestFocusInWindow(); } }); dialog.show(); if (pane.getValue().equals(new Integer(JOptionPane.OK_OPTION))) { if (!Arrays.equals(masterPassword.getPassword(), confirmedMasterPassword.getPassword())) { JOptionPane.showMessageDialog(mainWindow, Translator.translate("passwordsDontMatch")); } else { passwordsMatch = true; } } else { return; } } while (passwordsMatch == false); if (newDatabaseFile.exists()) { newDatabaseFile.delete(); } database = new PasswordDatabase(newDatabaseFile); dbPers = new PasswordDatabasePersistence(masterPassword.getPassword()); saveDatabase(); accountNames = new ArrayList(); doOpenDatabaseActions(); // If a "Database to Load on Startup" hasn't been set yet then ask the // user if they'd like to open this database on startup. if (Preferences.get(Preferences.ApplicationOptions.DB_TO_LOAD_ON_STARTUP) == null || Preferences.get(Preferences.ApplicationOptions.DB_TO_LOAD_ON_STARTUP).equals("")) { int option = JOptionPane.showConfirmDialog(mainWindow, Translator.translate("setNewLoadOnStartupDatabase"), Translator.translate("newPasswordDatabase"), JOptionPane.YES_NO_OPTION); if (option == JOptionPane.YES_OPTION) { Preferences.set(Preferences.ApplicationOptions.DB_TO_LOAD_ON_STARTUP, newDatabaseFile.getAbsolutePath()); Preferences.save(); } } }