如何使用JOption窗格的showInputDialog隐藏字符.例如:JOptionPane.showInputDialog("输入您的姓名:").
我想在用户提供他的名字时隐藏字符.我正处于申请中间.如果我可以隐藏这些角色,我的工作就完成了.我不想使用JPasswordField,因为它需要一个表单来保存该标签(JPasswordField).
public static String getName() {
JPasswordField jpf = new JPasswordField(24);
JLabel jl = new JLabel("Enter Your Name: ");
Box box = Box.createHorizontalBox();
box.add(jl);
box.add(jpf);
int x = JOptionPane.showConfirmDialog(null, box, "Name Entry", JOptionPane.OK_CANCEL_OPTION);
if (x == JOptionPane.OK_OPTION) {
return jpf.getText();
}
return null;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5034 次 |
| 最近记录: |