import java.awt.BorderLayout;
import javax.sound.sampled.LineUnavailableException;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.*;
public class ClientFrame extends JFrame
{
/**
*
*/
private static final long serialVersionUID = 1L;
Client client=null;
FileSender fileSender=null;
FileReceiver fileReceiver=null;
static VoiceReceive voiceReceive=null;
static VoiceSend voiceSend=null;
String fileTransFlag=null;//文件发送接收标记
static String VSip="";
static long filelength=0;
String filedir="";
BorderLayout borderLayout1 = new BorderLayout();
JPanel jPanel1 = new JPanel();
JPanel jPanel2 = new JPanel();
JPanel jPanel3 = new JPanel();
JPanel jPanel4 = new JPanel();
JPanel jPanel5 = new JPanel();
JLabel jLabel1 = new JLabel();
JTextField jip = new JTextField();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JLabel jLabel3 = new JLabel();
List list1 = new List();
BorderLayout borderLayout2 = new BorderLayout();
JLabel jnick=new JLabel();
JLabel jnickname = new JLabel();
JButton jButton3 = new JButton();
JTextArea jsend = new JTextArea(6,40);
JButton jButton4 = new JButton();
BorderLayout borderLayout3 = new BorderLayout();
JPanel jPanel6 = new JPanel();
JButton jButton5 = new JButton();
JButton jButton6 = new JButton();
List list2 = new List();
BorderLayout borderLayout4 = new BorderLayout();
JButton jButton7 = new JButton();
JButton jButton8 = new JButton();
JCheckBox jCheckBox1 = new JCheckBox();
JPanel jPanel7 = new JPanel();
JButton jButton9 = new JButton();
JButton jButton10 = new JButton();
JLabel jLabel4 = new JLabel();
JButton jButton11 = new JButton();
JFileChooser fileChooser=new JFileChooser();
JPanel jPanel9 = new JPanel();
static JProgressBar bar = new JProgressBar ();
static JLabel jLabel5 = new JLabel();
static JButton jButton12 = new JButton();
static JButton jButton13 = new JButton();
static JButton jButton14 = new JButton();
public ClientFrame()
{
try
{
jbInit();
}
catch (Exception exception)
{
JOptionPane.showMessageDialog(null,"对不起,有错误,请重启程序。","错误",JOptionPane.INFORMATION_MESSAGE);
}
}
private void jbInit() throws Exception
{
getContentPane().setLayout(borderLayout1);
jButton1.addActionListener(new ClientFrame_jButton1_actionAdapter(this));
jButton2.addActionListener(new ClientFrame_jButton2_actionAdapter(this));
jButton6.addActionListener(new ClientFrame_jButton6_actionAdapter(this));
jButton5.addActionListener(new ClientFrame_jButton5_actionAdapter(this));
jButton4.addActionListener(new ClientFrame_jButton4_actionAdapter(this));
jButton3.addActionListener(new ClientFrame_jButton3_actionAdapter(this));
jButton12.addActionListener(new ClientFrame_jButton12_actionAdapter(this));
jButton13.addActionListener(new ClientFrame_jButton13_actionAdapter(this));
jButton14.addActionListener(new ClientFrame_jButton14_actionAdapter(this));
jButton7.setText("jButton7");
jButton8.setText("清空消息");
jButton8.addActionListener(new ClientFrame_jButton8_actionAdapter(this));
jCheckBox1.setSelected(true);
jCheckBox1.setText("对所有人");
jPanel7.setLayout(new GridLayout(5,1));
jButton9.setText("发送");
jButton9.addActionListener(new ClientFrame_jButton9_actionAdapter(this));
jButton10.setText("开始");
jButton10.addActionListener(new ClientFrame_jButton10_actionAdapter(this));
jLabel4.setText("传输文件:");
jButton11.setText("接收");
jButton11.addActionListener(new ClientFrame_jButton11_actionAdapter(this));
this.getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH);
jip.setText("218.194.129.133");
jip.setColumns(15);
jButton1.setText("登陆");
jButton2.setText("退出");
jLabel3.setText("在线用户列表:");
jPanel2.setLayout(borderLayout2);
jnick.setText("昵称:");
jnickname.setText("昵称已然存在");
jButton3.setText("修改昵称");
jsend.setLineWrap(true);
jsend.setWrapStyleWord(true);
jButton4.setText("发送");
jPanel4.setLayout(borderLayout3);
jButton5.setText("查看历史消息");
jButton6.setText("保存消息");
jPanel6.setLayout(new GridLayout(3,1));
jPanel5.setLayout(borderLayout4);
jPanel1.add(jLabel1);
jPanel1.add(jip);
jPanel1.add(jButton1);
jPanel1.add(jButton2);
jPanel1.add(jnick);
jPanel1.add(jnickname);
jPanel1.add(jButton3);
jLabel1.setText("服务器IP地址:");
this.getContentPane().add(jPanel2, java.awt.BorderLayout.WEST);
jPanel2.add(list1, java.awt.BorderLayout.CENTER);
this.getContentPane().add(jPanel3, java.awt.BorderLayout.SOUTH);
jPanel3.add(jsend);
jPanel3.add(jButton4);
this.getContentPane().add(jPanel4, java.awt.BorderLayout.EAST);
jPanel6.add(jButton6, null);
jPanel6.add(jButton8);
jPanel6.add(jButton5, null);
this.getContentPane().add(jPanel5, java.awt.BorderLayout.CENTER);
jPanel5.add(list2, java.awt.BorderLayout.CENTER);
jPanel2.add(jLabel3, java.awt.BorderLayout.NORTH);
jPanel2.add(jCheckBox1, java.awt.BorderLayout.SOUTH);
jPanel4.add(jPanel6, java.awt.BorderLayout.NORTH);
jPanel4.add(jPanel7, java.awt.BorderLayout.SOUTH);
jPanel7.add(jLabel4);
jPanel7.add(jButton9);
jPanel7.add(jButton11);
jPanel7.add(jButton10);
this.setTitle("聊天室客户端");
this.setSize(800,600);
this.setLocation(100,100);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
/*
* 进度条处定义
*/
jPanel9.setLayout(new GridLayout(6,1));
jPanel4.add(jPanel9, java.awt.BorderLayout.CENTER);
bar.setForeground(new java.awt.Color(102, 255, 102));
//bar.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(204, 204, 204)), "总进度", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", 0, 13), new java.awt.Color(0, 0, 255)));
bar.setDoubleBuffered(true);
bar.setStringPainted ( true ) ;
bar.setSize (320,20);
jPanel9.add(jLabel5);
jPanel9.add(bar);
bar.setVisible(false);
jPanel9.add(jButton12);
jPanel9.add(jButton14);
jPanel9.add(jButton13);
jButton14.setText("接受语音");
jButton14.setVisible(false);
jButton12.setText("语音聊天");
jButton13.setText("拒绝语音");
jButton13.setVisible(false);
}
public static void main(String[] args)
{
ClientFrame clientframe = new ClientFrame();
}
public void jButton1_actionPerformed(ActionEvent e)
{
try
{
client = new Client(jip.getText(),9999, list1,list2);
}
catch (Exception ex)
{
JOptionPane.showMessageDialog(this,"服务器不存在或者没有启动!","提示",JOptionPane.ERROR_MESSAGE);
ex.printStackTrace();
}
if(jnickname.getText().length()>0)
{
this.client.send("NICKNAME:"+jnickname.getText());
}
else
{
JOptionPane.showMessageDialog(this,"为了便于区
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
ChatS.rar (17个子文件)
ChatServer
.project 386B
bin
Icon
GameButton.ico 1KB
src
Server.java 7KB
ServerFrame.java 11KB
Service.java 7KB
ChatTookit.java 4KB
.classpath 275B
ChatClient
.project 386B
bin
Icon
GameButton.ico 1KB
src
FileSender.java 2KB
ClientFrame.java 19KB
VoiceReceive.java 3KB
FileReceiver.java 2KB
Listener.java 4KB
Client.java 2KB
VoiceSend.java 3KB
.classpath 275B
共 17 条
- 1
资源评论
- xiawei90362012-10-23能够运行的
- wbp19882014-12-11作为课程设计参考是个不错的选择,多线程这块处理得还可以
kencbliove
- 粉丝: 3
- 资源: 29
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功