QQServer_update

import java.awt.*;
import javax.swing.*;
import java.net.*;
import java.io.*;
import java.awt.event.*; public class QQReg extends JFrame implements ActionListener{
public static void main(String[] args){
QQReg w = new QQReg();
w.setVisible(true);
} JTextField txtUser = new JTextField();
JPasswordField txtPass = new JPasswordField();
JPasswordField txtPassRe = new JPasswordField();
QQReg(){
//设置窗体的基本信息
this.setSize(660 , 380);
this.setLocationRelativeTo(null);
this.setTitle("Talking.GHOUL.Reg");
this.setResizable(false);
this.setIconImage(this.getToolkit().getImage("D:/lab_2/psb (11).jpg"));
//new组件&设置组件
JLabel labTitle = new JLabel(" SIGN UP ");
labTitle.setFont(new Font("", 0, 36)); JLabel labUser = new JLabel(" Username");
labUser.setFont(new Font("", 0, 30));
JLabel labPass = new JLabel(" Password");
labPass.setFont(new Font("", 0, 30));
JLabel labPassRe = new JLabel(" Confirm Password");
labPassRe.setFont(new Font("", 0, 30)); //------update-----------------------
//JComboBox cmbUsername = new JComboBox();
//cmbUsername.setFont(new Font("", 0, 30));
//cmbUsername.addItem("かねき けん");
//cmbUsername.addItem("Kaneki Ken");
//cmbUsername.addItem("金木 研");
txtUser.setFont(new Font("", 0, 30)); txtPass.setFont(new Font("", 0, 25));
txtPassRe.setFont(new Font("", 0, 25)); JButton btnReg = new JButton(" CONFIRM ");
btnReg.setFont(new Font("", 0, 30));
//注册事件监听
btnReg.addActionListener(this); //布置主面板
JPanel panUser = new JPanel();
panUser.setLayout(new GridLayout(3 , 3)); panUser.add(labUser);
panUser.add(txtUser);
panUser.add(labPass);
panUser.add(txtPass);
panUser.add(labPassRe);
panUser.add(txtPassRe);
//布置按钮面板
JPanel panButton = new JPanel();
panButton.setLayout(new FlowLayout()); panButton.add(btnReg);
//布置窗体
this.setLayout(new BorderLayout()); this.add(labTitle , BorderLayout.NORTH);
this.add(panUser , BorderLayout.CENTER);
this.add(panButton , BorderLayout.SOUTH);
} @Override
public void actionPerformed(ActionEvent arg0){
//System.out.println(arg0);
if(arg0.getActionCommand().equals(" CONFIRM ")){
try{
String user = txtUser.getText();
String pass = txtPass.getText();
Socket s = new Socket("127.0.0.1" , 8000); OutputStream os = s.getOutputStream();
OutputStreamWriter osw = new OutputStreamWriter(os);
PrintWriter pw = new PrintWriter(osw , true); pw.println(user+"%"+ pass);
}catch(Exception e){}
}
}
}
import java.io.*;
import java.net.*; public class QQServer{
public static void main(String[] args){
try{
//监听8000端口
ServerSocket ss = new ServerSocket(8000); System.out.println("等待客户端的消息...");
Socket s = ss.accept(); //接受用户名和密码
InputStream is = s.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr); String uandp = br.readLine(); //检验点
System.out.println(uandp);
}catch(Exception e){}
}
}
QQServer_update的更多相关文章
随机推荐
- Sqoop安装及操作
一.集群环境: Hostname IP Hadoop版本 Hadoop 功能 系统 node1 192.168.1.151 0.20.0 namenode hive+sqoop rhel5.4X86 ...
- ACM题目————Subsequence
Description A sequence of N positive integers (10 < N < 100 000), each of them less than or eq ...
- 第十一章 Android 内核驱动——Alarm
11.1 基本原理 Alarm 闹钟是 android 系统中在标准 RTC 驱动上开发的一个新的驱动,提供了一个定时器 用于把设备从睡眠状态唤醒,当然因为它是依赖 RTC 驱动的,所以它同时还可以 ...
- 如何调动员工的积极性 -引用LTP.Net知识库
也许是老板的意识不强,也许员工的意识薄弱,关于老板的意识强不强,我们只能看他是只顾眼前的利益,还是放眼于未来呢. 1:有一个领导的样子现在,在我国,聊天是非常时髦的,也非常受我们这个年龄段的人欢迎.如 ...
- c#danliemosih
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace 打印机 ...
- [Django_1_2]数据库设置
Django 数据库设置 本篇将介绍Django中的数据库设置,了解模型(models,数据库中的表项设计). 上一篇文章为:<a href="http://www.cnblogs.c ...
- 2015 AlBaath Collegiate Programming Contest B
Description Yaaaay, Haven't you heard the news? Bakaloria results are out! And Reem had very good gr ...
- 2016年10月14日 星期五 --出埃及记 Exodus 18:25
2016年10月14日 星期五 --出埃及记 Exodus 18:25 He chose capable men from all Israel and made them leaders of th ...
- MyBatis 3与spring整合之使用SqlSession
SqlSessionTemplate是MyBatis-Spring的核心.这个类负责管理MyBatis的SqlSession.调用MyBatis的SQL方法. SqlSessionTemplate是线 ...
- Python3基础 while配合random输出10个随机整数
镇场诗:---大梦谁觉,水月中建博客.百千磨难,才知世事无常.---今持佛语,技术无量愿学.愿尽所学,铸一良心博客.------------------------------------------ ...