I've tried several different ways to get userid/password using JOptionPane.

One was to use 2 different optionpanes to get id and pass separately. However, I would like to do it in one pass if possible. The following method works to get id/pass in one go, but the focus starts on the OK button. I would like it to focus on the userField so the user can just start typing.

Better yet would be a standard dialog for doing this, but...

     * A return value of false means the user hit cancel.
    private boolean login() {
      JTextField userField = new JTextField();
      JPasswordField passField = new JPasswordField();

      String message = "Please enter your user name and password.";
      Object[] options = { message, userField, passField };
      //Pop up the login dialog
      int result = JOptionPane.showOptionDialog(this,
          "Login", JOptionPane.OK_CANCEL_OPTION,
          null, null, null);
      //user hit OK
      if (result == JOptionPane.OK_OPTION) {
	        String id = userField.getText();
	        String pass = new String( passField.getPassword() );
	        //Try to validate the user using the provided id/pass
	        user = getLogin(id, pass);
	        return true;
      //user hit cancel
      return false;
Your help would be much appreciated.