JAVA初学:关于密码验证的问题?

来源:百度知道 编辑:UC知道 时间:2024/06/08 07:49:58
写一个JAVA程序:
1.密码数不可以少于8位
2.全是数字显示密码强度低
3.包含数字和小写字母显示密码强度中
4.包含数字.小写字母和大写字母显示密码强度高
因为JAVA刚学,可以用一些简单的语法,我怕看不懂,(我刚学到JAVA.LANG包)希望不要拷贝,加注释.可追加分。

import java.awt.*;
import java.awt.event.*;

public class TestPassword {
public static void main(String[]args) {
MyTestFrame mf = new MyTestFrame("密码输入");
}
}

class MyTestFrame extends Frame {
Button b = new Button("确认");
TextField tf = new TextField(15);

public MyTestFrame(String str){
super(str);
tf.setEchoChar('*');
Panel p = new Panel();
p.setBackground(Color.BLACK);
b.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {
String str = tf.getText();
// System.out.println(str);

if(str.length()<8) {
System.out.println("输入不能少于八位");
tf.setText("");

}
else {
if(str.matches("\\d*")) {
System.out.println("密码强度低 ");
}