⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 userlogin.java

📁 scoket 网络聊天室支持私聊
💻 JAVA
字号:
package chenmin.client;
import java.awt.*;
import java.awt.event.*;

import javax.swing.*;

/**
 * 类名:用户登陆类
 * 作用:显示用户登陆界面
 * 文件名:UserLogin.java
 * 最后修改日期 20060918
 * @author Chenmin
 */
public class UserLogin extends JFrame implements ActionListener
{
	String username;
	String password;
	boolean refresh=false;
	JLabel jlname;
	JLabel jlpass;
	JTextField jtname;
	JPasswordField jtpass;
	public UserLogin()
	{
		Container contentPane=getContentPane();
		//UserLoginListener ull=new UserLoginListener();
		//contentPane.setLayout(new GridBagLayout());
		jlname=new JLabel("帐号:");
		jlpass=new JLabel("密码:");
		jtname=new JTextField();
		jtname.setColumns(10);
		jtpass=new JPasswordField();
		jtpass.setColumns(10);
		JButton jbaccess=new JButton("登陆");
		jbaccess.addActionListener(this);
		JButton jbquit=new JButton("注册");
		jbquit.addActionListener(this);
		//contentPane.add(jlname,)
		JPanel pN=new JPanel();
		pN.add(jlname);
		pN.add(jtname);
		JPanel pP=new JPanel();
		pP.add(jlpass);
		pP.add(jtpass);
		JPanel pB=new JPanel();
		pB.add(jbaccess);
		pB.add(jbquit);
		contentPane.add(pN,BorderLayout.NORTH);
		contentPane.add(pP,BorderLayout.CENTER);
		contentPane.add(pB,BorderLayout.SOUTH);
		setTitle("MiniICQ");
		setSize(300,140);
		Dimension screen=getToolkit().getScreenSize();
		//pack();
		setLocation((screen.width-getSize().width)/2
				,(screen.height-getSize().height)/2);
		setVisible(true);
		pack();
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new UserLogin();

	}
	public void actionPerformed(ActionEvent ae) {
		// TODO Auto-generated method stub
		if(ae.getActionCommand().equals("登陆"))
		{
			//System.out.println("登陆");
			username=jtname.getText();
			password=jtpass.getText();
			refresh=true;
			setVisible(false);
		}
		if(ae.getActionCommand().equals("注册"))
		{
			System.out.println("注册");
			final JDialog jd=new JDialog();
			jd.add(new JLabel("暂时不能注册!"));
			jd.setSize(100,50);
			Dimension screen=getToolkit().getScreenSize();
			jd.setLocation((screen.width-getSize().width)/2
					,(screen.height-getSize().height)/2);
			jd.setVisible(true);
			jd.addWindowListener(new WindowAdapter()
					{
						public void windowClosing(WindowEvent e)
						{
							jd.setVisible(false);
						}
					}
			);
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -