import java.io.*;
import java.net.Socket;
import java.util.StringTokenizer;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.table.*;
import javax.swing.border.*;
public class Client主界面 extends ClientTest implements ActionListener{
private JFrame frame=new JFrame();
private JLabel label1,label2,label22,label3,label4,label5,label6,label7,label8;
private JTextArea text;
private JTextField path,ip;
private static Container con;
private JButton button1,button2,button3,button4,button41,button6,button5,button7,button8,button9,button10,button11,button12;
public ChatClient beginning;
private ImageIcon n1;
private ImageIcon n2;
private ImageIcon n3;
private List l;
private int i;
private String sending,sendmeg;
private Socket s,x;
private String[] osend;
private get g;
public Client主界面(){
frame.setSize(600,500);
frame.setTitle("客户端");
frame.setLocation(400,400);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
buju();
button8.setEnabled(false);
button9.setEnabled(false);
button10.setEnabled(false);
button11.setEnabled(false);
button12.setEnabled(false);
button41.setEnabled(false);
button7.setEnabled(false);
button5.setEnabled(false);
con.setBackground(Color.MAGENTA);
}
public void buju(){
con= frame.getContentPane();
//添加功能按钮///////////////
button2=new JButton("刷新");
button3=new JButton("接收");
button4=new JButton("连接");
button41=new JButton("断开");
button5=new JButton("ChatBar");;
button6=new JButton("CE");
button7=new JButton("共享的");
button8=new JButton("删除");
button9=new JButton("移动");
button10=new JButton("复制");
button11=new JButton("重命名");
button12=new JButton("下载");
l=new List();
label4=new JLabel("");
label5=new JLabel("");
label6=new JLabel("");
label7=new JLabel("");
n1=new ImageIcon("src//NO15.JPG");
label4.setIcon(n1);
n2=new ImageIcon("src//0.gif");
n3=new ImageIcon("src//8.gif");
button2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
l.clear();
connect(ip.getText());
connect1(ip.getText());
g = new get(s,x);
g.start();
}
});
button3.addActionListener(this);
button4.addActionListener(this);
button41.addActionListener(this);
button5.addActionListener(this);
button6.addActionListener(this);
button7.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
connect(ip.getText());
connect1(ip.getText());
g = new get(s,x);
g.start();
sendmeg=s.getInetAddress().getHostName()+" a";
g.start1(sendmeg);
button8.setBackground(Color.CYAN);
button9.setBackground(Color.CYAN);
button10.setBackground(Color.CYAN);
button11.setBackground(Color.CYAN);
button12.setBackground(Color.CYAN);
button8.setEnabled(true);
button9.setEnabled(true);
button10.setEnabled(true);
button11.setEnabled(true);
button12.setEnabled(true);
}
});
button8.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
performed1();
l.delItem(i);
sendmeg=osend[0]+" A"+" 1";
g.start1(sendmeg);
System.out.println(sendmeg);
}
});
button9.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
performed1();
l.delItem(i);
l.add(osend[0]);
sendmeg=osend[0]+" AA";
Thread thread=new Thread(new 试验());
thread.start();
}
});
button10.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
performed1();
l.add(osend[0]);
sendmeg=osend[0]+" AAA";
Thread thread=new Thread(new 试验());
thread.start();
}
});
button11.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
performed1();
// l.replaceItem(w.getText(), i);
sendmeg=osend[0]+" AAAA";
Thread thread=new Thread(new 试验());
thread.start();
}
});
button12.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
performed1();
sendmeg=osend[0]+" AAAAA";
g.start1(sendmeg);
}
});
JScrollPane pane12=new JScrollPane(l);
pane12.setBounds(65,240,400,150);
label4.setBounds(460,270,135,135);
label5.setBounds(5,130,30,30);
label6.setBounds(5,200,30,30);
label7.setBounds(5,250,50,50);
n1=new ImageIcon("NO15.JPG");
button3.setBounds(new Rectangle(5,20,60,20));
button4.setBounds(new Rectangle(5,50,60,20));
button41.setBounds(new Rectangle(5,80,60,20));
button2.setBounds(new Rectangle(5,110,60,20));
button5.setBounds(new Rectangle(470,230,100,50));
button5.setBorder(new BevelBorder(BevelBorder.RAISED));
button6.setBounds(new Rectangle(45,140,20,60));
button7.setBounds(new Rectangle(470,0,80,30));
button8.setBounds(new Rectangle(470,40,80,30));
button9.setBounds(new Rectangle(470,70,80,30));
button10.setBounds(new Rectangle(470,110,80,30));
button11.setBounds(new Rectangle(470,150,80,30));
button12.setBounds(new Rectangle(470,190,80,30));
con.add(button2);
con.add(button3);
con.add(button4);
con.add(button41);
con.add(button6);
con.add(button7);
con.add(button8);
con.add(button9);
con.add(button10);
con.add(button11);
con.add(button12);
con.add(pane12);
con.add(label4);
con.add(label5);
con.add(label6);
Font c = new Font(" ", 30, 20);
label1= new JLabel("对方IP:");
label1.setFont(c);
ip=new JTextField(20);
ip.setBounds(160,0,250,30);
label1.setBounds(70,0,100,30);
con.add(label1);
con.add(ip);
con.add(button5);
////////////////////添加文本
text=new JTextArea(100,100);
text.setEditable(false);
JScrollPane pane1=new JScrollPane(text);
pane1.setBounds(65,40,400,150);
pane1.setBackground(Color.cyan);
pane1.setBorder(new BevelBorder(BevelBorder.LOWERED));
////////////添加路径区
path=new JTextField(50);
path.setBackground(Color.LIGHT_GRAY);
path.setBounds(65,200,400,30);
path.setBorder(new BevelBorder(BevelBorder.LOWERED));
path.setEditable(true);
label3=new JLabel("");
label3.setBounds(5,350,10,5);
con.add(pane1);
con.add(path);
con.add(label3);
}
public void performed1(){
i = l.getSelectedIndex();
sending = l.getItem(i);
StringTokenizer s = new StringTokenizer(sending, " ");
osend=new String[4];
int k = 0;
while (s.hasMoreTokens()) {
osend[k] = s.nextToken();
k++;
}
System.out.println(osend[0]);
}
public void actionPerformed(ActionEvent e){
if(e.getSource().equals(button3)){//接收
try {
text.setText("");
sendMessage(text);
getMessage(path.getText(),text);
} catch (Exception ex) {
ex.printStackTrace();
}
}
if(e.getSource().equals(button4)){//连接
try{
label5.setIcon(n2);
button7.setBackground(Color.CYAN);
button5.setBackground(Color.CYAN);
button41.s
没有合适的资源?快使用搜索试试~ 我知道了~
java 局域网文件共享程序
共15个文件
java:12个
gif:2个
jpg:1个
5星 · 超过95%的资源 需积分: 9 41 下载量 63 浏览量
2010-09-24
12:40:05
上传
评论 2
收藏 29KB RAR 举报
温馨提示
本程序实现局域网内文件共享,下载,聊天等操作
资源推荐
资源详情
资源评论
收起资源包目录
FSS.rar (15个子文件)
FSS改进版
FileOperate.java 7KB
8.gif 5KB
ServerTest.java 2KB
NO15.JPG 3KB
Client主界面.java 13KB
0.gif 2KB
Server主界面.java 12KB
ClientTest.java 3KB
Build.java 10KB
ClientSocket.java 2KB
Enter口.java 680B
Login.java 3KB
Database.java 2KB
ChatServer.java 4KB
ChatClient.java 3KB
共 15 条
- 1
资源评论
- weidi3867440882014-12-21还行吧 功能基本实现了
- qq_149462432017-10-10好用的系统
- etscarecrow2011-12-09挺好用,不过功能比较单一。
Juice__
- 粉丝: 1
- 资源: 11
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功