PDA

View Full Version : How to put JPasswordField on JOptionPane.showInputDialog ?



om1559
یک شنبه 13 شهریور 1384, 23:03 عصر
salam,

man mikham tooye "JOptionPane.showInputDialog", yek "JPasswordField" bezaram.
khode showInputDialog ye JTextField generate mikone. vali man be ye JPasswordField ehtiaj daram.

chejoori mitoonam inkaro konam?

mamnoon

in code mane:



// JPasswordField pf = new JPasswordField();
// String str = new String (pf.getPassword());

String pass = JOptionPane.showInputDialog(null,
"Enter password to access:",
"Demanding Password",
JOptionPane.QUESTION_MESSAGE);

gorgin
یک شنبه 13 شهریور 1384, 23:45 عصر
JPasswordField pwd = new JPasswordField();
Object[] message = { "This is some message \n", pwd };
int resp = JOptionPane.showConfirmDialog(null, message,
"Retrieve Password", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
if(resp == JOptionPane.OK_OPTION) {
String pass = new String(pwd.getPassword());
}


Don't use showInputDialog, though, or it'll still put the plain text field