java qq注册页面_用Java做一个类似QQ注册界面 放在e:

展开全部

import java.awt.*;

import java.awt.event.*;

import java.io.*;

import java.util.*;

import javax.swing.*;

public class Output_GUI extends JFrame implements MouseListener

{

JLabel jLabel1,jLabel2,jLabel3;//定义三个标签32313133353236313431303231363533e4b893e5b19e31333337393539

JTextField jTextField1;//密码框

JPasswordField jPasswordField1;//

JButton jButton1,jButton2;

public Output_GUI()

{

this.setTitle("注册界面");

this.setBounds(100, 50, 330, 300);

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

Container con = this.getContentPane();

con.setLayout(null);

jLabel1 = new JLabel("注册");

jLabel2 = new JLabel("帐号:");

jTextField1 = new JTextField();

jLabel3 = new JLabel("密码:");

jPasswordField1 = new JPasswordField();

jButton1 = new JButton("注册");

jButton2 = new JButton("取消");

jButton1.addMouseListener(this);

jLabel1.setFont(new Font("宋体",Font.PLAIN ,12));

jLabel2.setFont(new Font("宋体",Font.PLAIN ,12));

jTextField1.setFont(new Font("宋体",Font.PLAIN ,12));

jLabel3.setFont(new Font("宋体",Font.PLAIN ,12));

jPasswordField1.setFont(new Font("宋体",Font.PLAIN ,12));

jButton1.setFont(new Font("宋体",Font.PLAIN ,12));

jButton2.setFont(new Font("宋体",Font.PLAIN ,12));

jButton2.setForeground(Color.blue);

jLabel1.setBounds(60, 10, 50, 25);

jLabel2.setBounds(60, 50, 50, 25);

jTextField1.setBounds(100, 50, 120, 20);

jLabel3.setBounds(60, 90, 50, 25);

jPasswordField1.setBounds(100, 90, 120, 20);

jButton1.setBounds(80, 150, 60, 25);

jButton2.setBounds(150, 150, 60, 25);

con.add(jLabel1);

con.add(jLabel2);

con.add(jTextField1);

con.add(jLabel3);

con.add(jPasswordField1);

con.add(jButton1);

con.add(jButton2);

}

public static void main(String[] args)

{

Output_GUI iO_GUI = new Output_GUI();

iO_GUI.setVisible(true);

}

public void mouseClicked(MouseEvent e)

{

if(e.getSource()==jButton1)

{

Map map = new HashMap();

map.put(jTextField1.getText(),jPasswordField1.getText());

FileOutputStream outFileStream = null;

ObjectOutputStream out = null;

try

{

outFileStream = new FileOutputStream("abc.txt");

out = new ObjectOutputStream(outFileStream);

out.writeObject(map);

}

catch (FileNotFoundException e3)

{

e3.printStackTrace();

}

catch (IOException e2)

{

e2.printStackTrace();

}

finally

{

try

{

out.close();

}

catch (IOException e1)

{

e1.printStackTrace();

}

}

JOptionPane.showMessageDialog(this, "注册成功");

}

else if (e.getSource()==jButton2)

{

}

}

public void mouseEntered(MouseEvent e) {

}

public void mouseExited(MouseEvent e) {

}

public void mousePressed(MouseEvent e) {

}

public void mouseReleased(MouseEvent e) {

}

}

刚刚写的,望采纳,谢谢楼主!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值