Here you can find the source of promptForDecryptionPassword()
private static String promptForDecryptionPassword()
//package com.java2s; // Licensed under GPL v3.0; see LICENSE for full text import java.awt.GridLayout; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JPasswordField; public class Main { private static String promptForDecryptionPassword() { // Set up custom JPanel with masked password field JPanel decryptionPasswordInputPanel = new JPanel(new GridLayout(1, 2)); JPasswordField decryptionPasswordPrompt = new JPasswordField(); decryptionPasswordInputPanel.add(new JLabel("Enter decryption password:")); decryptionPasswordInputPanel.add(decryptionPasswordPrompt); // Prompt for decryption password int result = JOptionPane.showConfirmDialog(null, decryptionPasswordInputPanel, "Decryption Password", JOptionPane.OK_CANCEL_OPTION); if (result == JOptionPane.OK_OPTION) { // OK selected return new String(decryptionPasswordPrompt.getPassword()); } else { // Dialog cancelled return null; }/* ww w. j a v a 2 s.c om*/ } }