建立一个密码设置窗口

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class JPasswordFieldDemo extends JApplet implements ActionListener{
    JLabel jl1,jl2,jl3;
    JPasswordField jp1,jp2;
    JButton jb1,jb2;
    JTextField jt1;
    public void init(){
        Container c=getContentPane();
        jl1=new JLabel("请输入您的密码",JLabel.CENTER);
        jl2=new JLabel("请再次输入密码",JLabel.CENTER);
        jl3=new JLabel("请您输入用户名",JLabel.CENTER);
        jt1=new JTextField(8);
        jp1=new JPasswordField(8);
        jp2=new JPasswordField(8);
        jb1=new JButton("提交");
        jb2=new JButton("取消");
        c.setLayout(new GridLayout(4,2));
        c.add(jl3);
        c.add(jt1);
        c.add(jl1);
        c.add(jp1);
        c.add(jl2);
        c.add(jp2);
        c.add(jb1);
        c.add(jb2);
        jb1.addActionListener(this);
        jb2.addActionListener(this);
    }
    public void actionPerformed(ActionEvent e){
        if(e.getSource()==jb1)
            if(jp1.getPassword().length>0)
                if(String.valueOf(jp1.getPassword()).equals(String.valueOf(jp2.getPassword())))
                    showStatus("密码输入成功!");
                else{
                    showStatus("两次输入的密码不同,请重新输入!");
                    jp1.setText("");
                    jp2.setText("");
                }
            else showStatus("密码不能为空!");
        if(e.getSource()==jb2){
            jt1.setText("");
            jp1.setText("");
            jp2.setText("");
            showStatus("");
        }
    }
        }
}