用户名称 登录密码
2014-05-21 23:43
106 查看
import javax.swing.*;import java.awt.*;import java.awt.event.*; //导入事件包中的所有类public class TextApp extends JFrame implements ActionListener{ private JLabel label1,label2,label3; private JTextField inputText; private JPasswordField inputPwd; public TextApp(){ super("单行文本框的应用"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); label1=new JLabel("用户名称:"); label2=new JLabel("登陆密码:"); inputText = new JTextField(" ",27); inputPwd = new JPasswordField(27); label3= new JLabel();
inputText.addActionListener(this);//添加监听器 inputPwd.addActionListener(this); Container cp= getContentPane(); cp.setLayout(new FlowLayout()); cp.add(label1); cp.add(inputText); cp.add(label2); cp.add(inputPwd);cp.add(label3); setSize(400,200); } public void actionPerformed(ActionEvent e){ //对回车事件的处理 if(e.getSource()==inputText)
{if (inputText.getText().indexOf('@') != -1) label3.setText("含有非法字符");}
else if(e.getSource()==inputPwd){
if (inputPwd.getPassword().length > 10 ) label3.setText("密码太长,请重新输入");
else if(inputPwd.getPassword().length < 6) label3.setText("密码太短,请重新输入");elselabel3.setText("成功");}
}
public static void main(String args[]){ TextApp frame=new TextApp(); frame.setVisible(true); } }
附件:http://down.51cto.com/data/2364450
inputText.addActionListener(this);//添加监听器 inputPwd.addActionListener(this); Container cp= getContentPane(); cp.setLayout(new FlowLayout()); cp.add(label1); cp.add(inputText); cp.add(label2); cp.add(inputPwd);cp.add(label3); setSize(400,200); } public void actionPerformed(ActionEvent e){ //对回车事件的处理 if(e.getSource()==inputText)
{if (inputText.getText().indexOf('@') != -1) label3.setText("含有非法字符");}
else if(e.getSource()==inputPwd){
if (inputPwd.getPassword().length > 10 ) label3.setText("密码太长,请重新输入");
else if(inputPwd.getPassword().length < 6) label3.setText("密码太短,请重新输入");elselabel3.setText("成功");}
}
public static void main(String args[]){ TextApp frame=new TextApp(); frame.setVisible(true); } }
附件:http://down.51cto.com/data/2364450
相关文章推荐
- MD5 加密登录用户名称和密码
- Windows网络用户登录密码的猜解
- 和用户、登录、密码与安全标识号(SID)一起移动数据库(转)
- ***** Windows网络用户登录密码的猜解 (VC++) *****
- ***** Windows网络用户登录密码的猜解 (VC++) *****
- 远程修改Serv-U FTP用户的登录密码
- 用户不小心忘记了密码,造成无法登录Windows2000 时怎么办?
- 用户登录密码框直接按回车提交,Submit按钮无法响应的有效解决办法
- ***** Windows网络用户登录密码的猜解 (VC++) *****
- ***** Windows网络用户登录密码的猜解 (VC++) *****
- [转] 登录失败:用户帐户限制。可能的原因包括不允许空密码,登录时间限制,或强制的策略限制。
- WINDOWS 2000下如何获得用户登录名和密码 (远程注入)
- 新增用户时设置了用户下次登录必须修改密码造成OWA无法登录
- WINDOWS 2000下如何获得用户登录名和密码
- ***** Windows网络用户登录密码的猜解 (VC++) *****
- Oracle Sys用户用默认密码change_on_install 无法登录的问题(错误代码:ORA-28009)
- 关于AD用户不输入用户名和密码直接登录网站的说明
- 如何清除XP的开机用户登录密码
- 自定义函数//获取登录计算机用户的名称,获取计算机名称
- 在SharePoint中更改当前登录用户的密码