Creating a static method like JOptionPane.showInputDialog() but with my own components in the dialog box
How can write a method that can be used to instantiate an 开发者_StackOverflow中文版object through a dialog, and will not instantiate that object until input has been received? For example, instead of
int i = JOptionPane.showInputDialog("Enter number: ")
how could I have something like char[] c = className.showPasswordDialog("Enter password: ")
with a JPasswordField instead of a text field?JPasswordField pwf = new JPasswordField();
JOptionPane.showInputDialog(pwf);
char[] pswd = pwf.getPassWord();
精彩评论