您好,欢迎光临本网站![请登录][注册会员]  
文件名称: 用户登录Java程序
  所属分类: Java
  开发工具:
  文件大小: 5kb
  下载次数: 2
  上传时间: 2009-06-15
  提 供 者: luckb******
 详细说明: import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Text extends JFrame implements ActionListener,TextListener { private JLabel username,password,email,telephone; private JTextField usernameField,emailField; private TextFie ld teleField; private JPasswordField passwordField; private JButton registButton,cancelButton; public Text() { super("用户注册"); Container container = getContentPane(); container.setLayout(new FlowLayout()); username = new JLabel("用户名"); username.setToolTipText("请输入用户名"); password = new JLabel("密 码"); password.setToolTipText("密码不能少于6位"); email = new JLabel("邮 箱"); email.setToolTipText("邮箱中必须包含@字符"); telephone = new JLabel("电 话"); telephone.setToolTipText("电话只能为数字"); usernameField = new JTextField(15); usernameField.addActionListener(this); passwordField = new JPasswordField(15); passwordField.addActionListener(this); emailField = new JTextField(15); emailField.addActionListener(this); teleField = new TextField(21); teleField.addActionListener(this); teleField.addTextListener(this); registButton = new JButton("注册"); cancelButton = new JButton("取消"); container.add(username); container.add(usernameField); container.add(password); container.add(passwordField); container.add(email); container.add(emailField); container.add(telephone); container.add(teleField); container.add(registButton); container.add(cancelButton); registButton.addActionListener(this); cancelButton.addActionListener(this); setSize(250,200); setVisible(true); setResizable(false); } public void textValueChanged(TextEvent event) { if (event.getSource() == teleField) { /*if (!checkNumber(teleField.getText())) { JOptionPane.showMessageDialog(this,"电话必须为数字","温馨提示",JOptionPane.INFORMATION_MESSAGE); teleField.setText(""); } */ } } public void actionPerformed(ActionEvent event) { if (event.getSource() == usernameField) { if (usernameField.getText().equals("")) { JOptionPane.showMessageDialog(null,"用户名不能为空","温馨提示",JOptionPane.INFORMATION_MESSAGE); } } if (event.getSource() == passwordField) { if (passwordField.getPassword().length == 0) { JOptionPane.showMessageDialog(this,"密码不能为空","温馨提示",JOptionPane.INFORMATION_MESSAGE); } else if (passwordField.getPassword().length < 6) { JOptionPane.showMessageDialog(this,"密码长度不能小于6位","温馨提示",JOptionPane.INFORMATION_MESSAGE); passwordField.setText(""); } } if (event.getSource() == emailField) { if (emailField.getText().indexOf("@") < 0 || emailField.getText().indexOf("@") >= (emailField.getText().length() - 1) || emailField.getText().equals("")) { JOptionPane.showMessageDialog(this,"您的邮箱格式不正确","温馨提示",JOptionPane.INFORMATION_MESSAGE); emailField.setText(""); } } if (event.getSource() == teleField) { if (teleField.getText().equals("")) { JOptionPane.showMessageDialog(this,"联系电话不能为空","温馨提示",JOptionPane.INFORMATION_MESSAGE); } else if (!checkNumber(teleField.getText())) { JOptionPane.showMessageDialog(this,"电话必须为数字","温馨提示",JOptionPane.INFORMATION_MESSAGE); teleField.setText(""); } } if (event.getSource() == registButton) { if (usernameField.getText().equals("") || passwordField.getPassword().length == 0 || emailField.getText().equals("") || teleField.getText().equals("")) { JOptionPane.showMessageDialog(this, "您填写的信息不完整","温馨提示",JOptionPane.INFORMATION_MESSAGE); usernameField.setText(""); passwordField.setText(""); emailField.setText(""); teleField.setText(""); } else if (passwordField.getPassword().length < 6) { JOptionPane.showMessageDialog(this,"密码长度不能小于6位","温馨提示",JOptionPane.INFORMATION_MESSAGE); passwordField.setText(""); } else if (emailField.getText().indexOf("@") < 0 || emailField.getText().indexOf("@") >= (emailField.getText().length() - 1)) { JOptionPane.showMessageDialog(this,"您的邮箱格式不正确","温馨提示",JOptionPane.INFORMATION_MESSAGE); emailField.setText(""); } else if (!checkNumber(teleField.getText())) { JOptionPane.showMessageDialog(this,"电话必须为数字","温馨提示",JOptionPane.INFORMATION_MESSAGE); teleField.setText(""); } else JOptionPane.showMessageDialog(this,"恭喜您,注册成功","温馨提示",JOptionPane.INFORMATION_MESSAGE); } if (event.getSource() == cancelButton) { usernameField.setText(""); passwordField.setText(""); emailField.setText(""); teleField.setText(""); } } public boolean checkNumber(String str) { for (int i=0;i
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 相关搜索: Java程序
 输入关键字,在本站1000多万海量源码库中尽情搜索: