How can I give this password field focus?
问题 This may seem trivial, but I can't figure out how to give the password box in this dialog focus. import javax.swing.JOptionPane; import javax.swing.JPasswordField; public class PasswordBox { @SuppressWarnings("unused") public String prompt() { JPasswordField pass = new JPasswordField(10); int action = JOptionPane.showConfirmDialog(null, pass,"Enter Password",JOptionPane.OK_CANCEL_OPTION); return new String(pass.getPassword()); } } I invoke it from other classes like this: String tmpPASS = new