JPasswordField の色をキー Listener で変更したいと考えています。登録フォームを作成していますが、ユーザーはパスワード フィールドに数字と文字を含む 8 文字以上を入力する必要があります。誰でも私を助けることができますか?
私のコード:
enter code here
public void keyPressed(KeyEvent e) {
if(e.getSource()==passwordField){
if(passwordField.toString().length()>=8)
passwordField.setBackground(Color.GREEN);
else
passwordField.setBackground(Color.RED);
}
}