高级语言案例分析_QQ_登录

package javaQQ;

import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

import com.sun.org.apache.bcel.internal.generic.NEW;

public class Load_QQ extends JFrame {
	User_QQ userQQ=new User_QQ();
	static String un;
	boolean Flag=false;
	private JLabel welcomela=null;
	
	private JLabel servela=null;
	private	 JLabel userla=null;
	private JLabel passwordla=null;
	private JTextField servejt=null;
	private JTextField userjt=null;
	private JPasswordField passwordjp=null;
	
	private JButton loadbtn=null;
	private JButton canclebtn=null;
	private JButton loginbtn=null;
	private JPanel inputJp=null;
	private JPanel btnJp=null;
	
	
	public Load_QQ(){
		super("用户登陆");
		init();
	}
	
	public void init(){
		inputJp=new JPanel();
		btnJp=new JPanel();
		this.setLayout(new FlowLayout());
		inputJp.setLayout(new GridLayout(3,2));
		welcomela=new JLabel("欢迎使用javaQQ");
		servela=new JLabel("服务器:");
		userla=new JLabel("用户名:");
		passwordla=new JLabel("密    码:");
		servejt=new JTextField("shenzhaowei_QQ");
		userjt=new JTextField(10);
		passwordjp=new JPasswordField(10);
		loadbtn=new JButton("登陆");
		canclebtn=new JButton("取消");
		loginbtn=new JButton("注册");
		inputJp.add(servela);
		inputJp.add(servejt);
		inputJp.add(userla);
		inputJp.add(userjt);
		inputJp.add(passwordla);	
		inputJp.add(passwordjp);
		btnJp.add(loadbtn);
		btnJp.add(canclebtn);
		btnJp.add(loginbtn);
		
		this.add(welcomela);
		this.add(inputJp);
		this.add(btnJp);
		this.setSize(260,260);
		this.setVisible(true);
		this.show();
		
		loadbtn.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				String serveName=servejt.getText().trim();
				String userName=userjt.getText().trim();
				String passwordStr=passwordjp.getText().trim();
				int i;
				for(i=0;i<userQQ.userpasswordU.length;i++){
					
					
					System.out.println("userpasswordU:"+userQQ.userpasswordU[i]);
					System.out.println("passwordStr:"+passwordStr);
					
					
					if(userQQ.usernameU[i].equals(userName)){
						System.out.println("usernameU:"+userQQ.usernameU[i]);
						System.out.println("userName:"+userName);
						un=userQQ.usernameU[i];
						if(userQQ.userpasswordU[i].equals(passwordStr)){
							System.out.println("userpasswordU:"+userQQ.userpasswordU[i]);
							System.out.println("passwordStr:"+passwordStr);
							Flag=true;
							break;
						}
					}
				}
				System.out.println(Flag);
				System.out.print("un:"+un);
				if(Flag==true){					
					close();
					Friend_QQ friendQQ=new Friend_QQ(un);
				}
			}
		});
		loginbtn.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				Login_QQ lg=new Login_QQ();
				close();
			}
		});
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
		canclebtn.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				System.exit(0);
			}
		});
	}
	public void close(){
		this.dispose();
	}
	public static void main(String args[]){
		Load_QQ ld=new Load_QQ();
	}

}

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值