I think SubmitBtn is a very bad name for a listener. Convention has it that the name should end “…Listener”.
Why are you taking a
char[] from the password field and then converting it to a
String? Don't. Validate the
char[] only, then fill it with a default character, e.g.
Arrays.fill(pwd, '\0'); when you have finished with it.
Why are you setting the text to show a valid password before you have validated it?
Why does your message say anything about
nulls? Is it possible for the password to be
null at all? Why are you
testing for length 0 and later for length < 7?
Don7apos;t throw an Exception and catch ti in the same method. That is simply an inefficient way to write an
if‑else.
You can create different messages, but your block of
ifs can't cope with a password like
HxrTG, which will fail for not having a number, and will never reach the test for < 7 characters.