- 2
- 0
- 约1.92万字
- 约 23页
- 2020-08-01 发布于上海
- 举报
源代码
项目QQClientProject:
LoguiGui代码:
package com.huaxia.qq.mzz.gui;
import com.huaxia.qq.mon.Message;
import com.huaxia.qq.mzz.common.MessageService;
import com.huaxia.qq.mzz.common.User;
import java.net.Socket;
import javax.swing.JOptionPane;
public class LoguiGui extends javax.swing.JFrame {
public LoguiGui() {
initComponents();
}
public Socket connectServer() {
Socket s = null;
try {
s = new Socket("127.0.0.1, 6666);
} catch (Exception e) {
e.printStackTrace();
}
return s;
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String name = nameItem.getText();
System.out.println(用户名: + name);
if (name == null || .equals(name)) {
JOptionPane.showMessageDialog(this, 用户名不能为空,请输入, 异常提示, JOptionPane.ERROR_MESSAGE);
return;
}
String pwd = new String(pwdItem.getPassword());
System.out.println("密码: + pwd);
if (pwd.length() == 0) {
JOptionPane.showMessageDialog(this, 密码不能为空,请输入, 异常提示, JOptionPane.ERROR_MESSAGE);
return;
}
final Socket s = this.connectServer();
//构造消息
final User u = new User(name, pwd);
Message msg = new Message(1, u);
//执行发送
MessageService.getInstance().sendMsg(msg, s);
//接受消息【接收注册结果】
Message result = MessageService.getInstance().receiveMsg(s);
// 取出注册成功的标志
String r = (String) result.getBody();
if (r == null) {//注册成功
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new ChatGui(u, s).setVisible(true);
}
});
this.dispose();
} else {
JOptionPane.showMessageDialog(this, "登录失败:" + r, 异常提示, JOptionPane.INFORMATION_MESSAGE);
}
private void jLabel3MouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
final LoguiGui gui = this;
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
RegiterGui dialog = new RegiterGui(gui, true);
dialog.setLocationRelativeTo(gui);
dialog.setVisible(true);
}
});
}
private void jButton2MouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
nameItem.setText(null);
pwdItem.setText(null);
您可能关注的文档
- itv高清机顶盒设置方法.doc
- it技术行业-商业计划书怎么写.doc
- java+sql教学管理系统.doc
- javascript基础之数组使用.doc
- java-se-unit07:-基本io操作-、-文本数据io操作.docx
- java办公自动化系统(源代码及全套资料).doc
- java编程规范【整理】.doc
- java程序设计实例教程考试题.docx
- java程序设计作业3.doc
- java抽奖系统源代码.doc
- G681线阿勒泰至禾木喀纳斯公路建设项目增补观景停车区等服务设施项目环境影响报告表.pdf
- 来宾韦文林建材年产100万吨机制砂项目环境影响报告表.pdf
- 合山市高端环保免漆生态板加工项目环境影响报告表.pdf
- 3.5万吨_年生物基丁二酸及衍生物高端制造项目(重新报批)报告书.pdf
- G631淮阳区王店至周西路口段新建工程报告书.pdf
- 年产12万吨装配式智能钢结构、50万套钢结构工程机械配件智能自动化生产线项目环境影响报告书.doc
- 2024年新疆维吾尔自治区福海县渔业绿色循环发展试点-生态型活鱼育肥箱系统采购项目环境影响报告表.pdf
- 广西1828大健康产业园项目环境影响报告表.pdf
- 220千伏金秀站扩建工程环境影响报告表.pdf
- 20万吨_年聚苯乙烯产品优化提升项目报告书.pdf
原创力文档

文档评论(0)