I've just tested it (again) and componentListener works fine, the 2nd or 3rd
or whatever textField/passwordField starts off with the focus (
java 1.6)
these are the basic rules you have to follow for focus
1)
use requestFocusInWindow() rather than requestFocus()
2)
requestFocusInWindow() will only work if the component is visible, so, if you have
pwd.requestFocusInWindow();
frame.setVisible(true);//where frame, in its hierarchy, has pwd
it won't work, it has to be
frame.setVisible(true);
pwd.requestFocusInWindow();
assuming you are still working with a JDialog (because of the passwordField),
and the dialog is modal, the above does not apply because once a modal dialog's
visibility is set to true, all code following is not executed until the dialog is disposed.
a componentListener will overcome the above problem, but it has to be added
prior to the dialog's setVisible(true) (for obvious reasons).
if you still have problems you will have to post the code you are trying,
so we can see what you are doing.