/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* ChartGui.java
*
* Created on 2012-7-24, 10:00:16
*/
package com.itjob.contact.client.gui;
import com.itjob.contact.client.Client;
import com.itjob.contact.client.ClientWorker;
import com.itjob.contact.common.IMessageService;
import com.itjob.contact.common.Message;
import com.itjob.contact.common.MessageType;
import com.itjob.contact.common.SocketMessageService;
import com.itjob.contact.common.User;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.swing.DefaultListModel;
/**
*
* @author Administrator
*/
public class ChartGui extends javax.swing.JFrame {
private Client c;
private User u;
/** Creates new form ChartGui */
public ChartGui(User u, Client c) {
this.c = c;
this.u = u;
initComponents();
this.setTitle(u.getLoginName());
//必须要不断地接收消息
//构造客户端的秘书类
new ClientWorker(this).start();
}
public Client getC() {
return c;
}
public void setC(Client c) {
this.c = c;
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
jList1 = new javax.swing.JList();
jScrollPane2 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
jScrollPane3 = new javax.swing.JScrollPane();
jTextArea2 = new javax.swing.JTextArea();
jButton1 = new javax.swing.JButton();
jCheckBox1 = new javax.swing.JCheckBox();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
formWindowClosing(evt);
}
});
jList1.setModel(new DefaultListModel());
jList1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jList1MouseClicked(evt);
}
});
jScrollPane1.setViewportView(jList1);
jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jScrollPane2.setViewportView(jTextArea1);
jTextArea2.setColumns(20);
jTextArea2.setRows(5);
jScrollPane3.setViewportView(jTextArea2);
jButton1.setText("发送");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jCheckBox1.setText("私聊");
jCheckBox1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jCheckBox1ActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 277, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 277, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(32, 32, 32))
.addGroup(layout.createSequentialGroup()
.addGap(132, 132, 132)
.addComponent(jButton1)
.addGap(18, 18, 18)
.addComponent(jCheckBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(133, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 34, Short.MAX_VALUE)
.addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 259, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton1)
.addContainerGap())
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jCheckBox1)
.addContainerGap())))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
Message msg = new Message(MessageType.MSG_TEXT, u);
List<User> msgTo = null;
//发送消息
DefaultListModel dlm = (DefaultListModel) jList1.getModel();
int[] i = jList1.getSelectedIndices();
if (i[0] == 0) {
System.out.println("chartgui publicchat");
msg = new Message(MessageType.MSG_PUBLICCHAT, u);
} else {
msgTo = new ArrayList<User>();
for (int j = 0; j < i.length; j++) {
msgTo.add((User) dlm.elementAt(i[j]));
}
/* c.sendMessage((new User(this.getTitle())),msgTo,chatMessage);
msg.setText(msg.getText()+new User(this.getTitle())+":"+chatMessage+"\n");//娑堟伅鍘嗗彶+鍙戦€佽€咃細鍙戦€佺殑娑堟伅
sendMsg.setText(" ");//灏嗘瘡娆″彂閫佹秷鎭殑闈㈡澘缃┖
*/
}
msg.setMsgSender(u);//5
// User tu=new User("2","2");
// List<User> tul=new ArrayList<User> ();
// tul.add(tu);
/// msg.setType(MessageType.MSG_TEXT);
msg.setMsgTo(msgTo);
msg.setMsgBody(jTextArea2.getText());
IMessageService proxy = new SocketMessageService(c.getS());
proxy.sendMessage(msg);
//接收注册结果
}//GEN-LAST:event_jButton1ActionPerformed
private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox1ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jCheckBox1ActionPerformed
private void jList1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jList1MouseClicked
// TODO add your handling code here:
}//GEN-LAST:event_jList1MouseClicked
private void formWindowClosing(java.awt.event.WindowEvent
没有合适的资源?快使用搜索试试~ 我知道了~
NETBEANS下的网络QQ聊天系统
共75个文件
class:26个
java:16个
xml:12个
4星 · 超过85%的资源 需积分: 10 76 下载量 85 浏览量
2012-07-31
09:38:48
上传
评论 2
收藏 86KB RAR 举报
温馨提示
NETBEANS下的网络QQ聊天系统,精研实用,值得收藏!
资源推荐
资源详情
资源评论
收起资源包目录
nbspace-ok-full.rar (75个子文件)
nbspace
ContactServer
manifest.mf 85B
users.data 276B
src
contactserver
ContactServer.java 418B
com
itjob
contact
server
Server.java 2KB
ServerWorker.java 7KB
build
classes
contactserver
ContactServer.class 540B
com
itjob
contact
server
Server.class 2KB
ServerWorker.class 5KB
.netbeans_automatic_build 0B
build.xml 4KB
nbproject
genfiles.properties 475B
project.properties 2KB
private
private.xml 211B
config.properties 0B
private.properties 190B
build-impl.xml 56KB
project.xml 959B
ContactClient
manifest.mf 85B
src
contactclient
ContactClient.java 294B
com
itjob
contact
client
gui
RegisterGui.java 6KB
RegisterGui.form 5KB
ChartGui.java 10KB
LoginGui.java 8KB
LoginGui.form 6KB
ChartGui.form 7KB
ClientWorker.java 3KB
Client.java 2KB
build
classes
contactclient
ContactClient.class 410B
com
itjob
contact
client
Client.class 2KB
gui
LoginGui$3.class 955B
ChartGui$3.class 858B
LoginGui$2.class 826B
ChartGui$2.class 826B
LoginGui$5.class 592B
ChartGui.class 9KB
RegisterGui.class 5KB
ChartGui$1.class 831B
LoginGui$4.class 1KB
LoginGui$1.class 858B
ChartGui$4.class 858B
RegisterGui$1.class 879B
LoginGui.class 7KB
ClientWorker.class 3KB
.netbeans_automatic_build 0B
build.xml 4KB
nbproject
genfiles.properties 475B
project.properties 2KB
private
private.xml 211B
config.properties 0B
private.properties 190B
build-impl.xml 56KB
project.xml 959B
ContactCommon
manifest.mf 85B
src
com
itjob
contact
common
IMessageService.java 405B
User.java 2KB
Message.java 2KB
MessageType.java 508B
FileUserService.java 3KB
IUserService.java 295B
SocketMessageService.java 1KB
build
classes
com
itjob
contact
common
User.class 2KB
MessageType.class 2KB
IMessageService.class 306B
FileUserService.class 3KB
IUserService.class 308B
SocketMessageService.class 2KB
Message.class 3KB
.netbeans_automatic_build 0B
build.xml 4KB
nbproject
genfiles.properties 475B
project.properties 2KB
private
private.xml 211B
private.properties 120B
build-impl.xml 55KB
project.xml 521B
共 75 条
- 1
资源评论
- tianmiaoDaisy2013-11-16刚刚学习netbeans,对学习很有帮助
- NJNBJL2014-01-13还可以,有需要更改的地方
- RTAAAAAQBHJE2018-01-11对初学者还可以
- amyitishao2014-04-06挺好的,但还是有需要更改的地方
buddha17
- 粉丝: 37
- 资源: 56
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 模拟题最终版.docx
- Java Web实验报告一:通讯录
- 不同温度下的光谱数据,仅截取550nm-700nm
- 不同温度下的光谱数据,仅截取550nm-700nm
- HengCe-18900-2024-2030全球与中国eMMC和UFS市场现状及未来发展趋势-样本.docx
- 2024第十四届APMCM亚太地区-C题完整论文.pdf
- HengCe-18900-2024-2030中国硬碳负极材料市场现状研究分析与发展前景预测报告-样本.docx
- PHP面向对象与设计模式
- HengCe-2024-2030全球与中国掩模基板市场现状及未来发展趋势-样本
- CSS3制作的聚光灯下倒影文字选装动画特效代码.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功