import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import java.io.*;
import java.net.*;
import java.text.SimpleDateFormat;
import java.util.*;
import javax.swing.*;
import javax.swing.border.TitledBorder;
public class JFTP extends JFrame implements ActionListener{
/**
* JFTP服务器 authors:钟吉程,潘黎,蒋先柒
*/
private static final long serialVersionUID = 1L;
//全局控件
JLabel jlport,jlmost,jluser,jlpassword,jlwelcome,jlexit;
JLabel jldownload,jlupload,jlchangename,jldelete,jlcreate;
JLabel jlstartwithsystem,jllistening,jlmin;
//JTextField ;
static JTextField jtfuser,jtfpath,jtfpassword,jtfport,jtfmost,jtfwelcome,jtfexit;
//JTextField ;
JButton jbpath,jbstart,jbstop,jbquit;
JFileChooser jfcpath;
JPanel jpcheckbox;
static JCheckBox jcbdownload,jcbupload,jcbchangename,jcbdelete,jcbcreate,jcbstartwithsystem,jcblistening,jcbmin;
public MFTP mftp;
public ServerSocket Ssocket;
//构造函数
public JFTP(){
jlport = new JLabel("监听端口:");
jtfport=new JTextField("21");//端口TextField
jlmost=new JLabel("最大连接:");
jtfmost=new JTextField("20");//最大连接数
jluser=new JLabel("帐号名称:");
jtfuser=new JTextField("admin");//用户名
jlpassword=new JLabel("帐号密码:");
jtfpassword=new JTextField("admin");//用户密码
jlwelcome=new JLabel("欢迎信息:");
jtfwelcome=new JTextField("欢迎访问~!");//欢迎信息
jlexit=new JLabel("退出信息:");
jtfexit=new JTextField("欢迎下次光临~!");//退出信息
jbpath=new JButton("访问目录");
jtfpath=new JTextField("f:\\");//访问目录
jfcpath=new JFileChooser();
jfcpath.setDialogTitle("打开文件...");
jbstart=new JButton("启动服务");
jbstop=new JButton("停止服务");
jbquit=new JButton("退出程序");
jlstartwithsystem=new JLabel("系统启动时启动");
jllistening=new JLabel("启动后开始监听");
jlmin=new JLabel("启动后最小化");
jpcheckbox=new JPanel();
jldownload=new JLabel("下载文件");
jlupload=new JLabel("上传文件");
jlchangename=new JLabel("文件更名");
jldelete=new JLabel("删除文件");
jlcreate=new JLabel("创建目录");
jcbdownload=new JCheckBox();
jcbupload=new JCheckBox();
jcbchangename=new JCheckBox();
jcbdelete=new JCheckBox();
jcbcreate=new JCheckBox();
jcbstartwithsystem=new JCheckBox();
jcblistening=new JCheckBox();
jcbmin=new JCheckBox();
//填空组控件
jlmost.setFont(new Font("宋体",0,12));
jtfport.setBounds(65,10,80,20);
jlport.setBounds(10,10,60,20);
jlport.setFont(new Font("宋体",0,12));
jlmost.setBounds(10,31,60,20);
jtfmost.setBounds(65,31,80,20);
jluser.setFont(new Font("宋体",0,12));
jluser.setBounds(10,52,60,20);
jtfuser.setBounds(65,52,80,20);
jlpassword.setFont(new Font("宋体",0,12));
jlpassword.setBounds(10,73,200,20);
jtfpassword.setBounds(65,73,80,20);
jlwelcome.setFont(new Font("宋体",0,12));
jlwelcome.setBounds(10,94,60,20);
jtfwelcome.setBounds(65,94,280,20);
jlexit.setFont(new Font("宋体",0,12));
jlexit.setBounds(10,115,60,20);
jtfexit.setBounds(65,115,280,20);
jbpath.setFont(new Font("宋体",0,12));
jbpath.setMargin(new Insets(0, 0, 0, 0)); //设置按钮内没空间
jbpath.setBounds(1,136,60,20);
jtfpath.setBounds(65,136,280,20);
jbstart.setFont(new Font("宋体",0,12));
jbstart.setMargin(new Insets(0, 0, 0, 0));
jbstart.setBounds(275,10,70,20);
jbstop.setFont(new Font("宋体",0,12));
jbstop.setMargin(new Insets(0, 0, 0, 0));
jbstop.setBounds(275,40,70,20);
jbquit.setFont(new Font("宋体",0,12));
jbquit.setMargin(new Insets(0, 0, 0, 0));
jbquit.setBounds(275,70,70,20);
//操作权限内控件
jpcheckbox.setBounds(0,158,356,50);
//jpchackbox.setBackground(Color.white);
//jpchackbox.setBorder(BorderFactory.createLineBorder(new Color(80,80,80)));
jpcheckbox.setBorder(BorderFactory.createTitledBorder(
BorderFactory.createEtchedBorder(),"操作权限",TitledBorder.LEFT,TitledBorder.TOP));
jpcheckbox.setLayout(null);
jldownload.setFont(new Font("宋体",0,12));
jlupload.setFont(new Font("宋体",0,12));
jlchangename.setFont(new Font("宋体",0,12));
jldelete.setFont(new Font("宋体",0,12));
jlcreate.setFont(new Font("宋体",0,12));
jcbdownload.setBounds(3,20,17,17);
jldownload.setBounds(23,18,60,20);
jcbupload.setBounds(73,20,17,17);
jlupload.setBounds(93,18,60,20);
jcbchangename.setBounds(143,20,17,17);
jlchangename.setBounds(163,18,60,20);
jcbdelete.setBounds(213,20,17,17);
jldelete.setBounds(233,18,60,20);
jcbcreate.setBounds(283,20,17,17);
jlcreate.setBounds(303,18,60,20);
//系统启动功能选择控件
jcbstartwithsystem.setBounds(155,10,17,17);
jlstartwithsystem.setFont(new Font("宋体",0,12));
jlstartwithsystem.setBounds(175,8,100,20);
jcblistening.setBounds(155,40,17,17);
jllistening.setFont(new Font("宋体",0,12));
jllistening.setBounds(175,38,100,20);
jcbmin.setBounds(155,70,17,17);
jlmin.setFont(new Font("宋体",0,12));
jlmin.setBounds(175,68,100,20);
//JFrame内添加的控件
add(jlport);add(jlmost);add(jluser);add(jlpassword);
add(jlwelcome);add(jlexit);add(jtfport);add(jtfmost);
add(jtfuser);add(jtfpassword);add(jtfwelcome);
add(jtfexit);add(jtfpath);add(jbpath);add(jbstart);
add(jbstop);add(jbquit);add(jpcheckbox);
add(jcbstartwithsystem);add(jlstartwithsystem);
add(jcblistening);add(jllistening);
add(jcbmin);add(jlmin);
//Panel内添加的控件
jpcheckbox.add(jcbdownload);jpcheckbox.add(jldownload);jpcheckbox.add(jcbupload);jpcheckbox.add(jlupload);
jpcheckbox.add(jcbchangename);jpcheckbox.add(jlchangename);jpcheckbox.add(jcbdelete);jpcheckbox.add(jldelete);
jpcheckbox.add(jcbcreate);jpcheckbox.add(jlcreate);
//监听
jbstop.setEnabled(false);
jbpath.addActionListener(this);
jbstart.addActionListener(this);
jbstop.addActionListener(this);
jbquit.addActionListener(this);
//jcbstartwithsystem.addActionListener(this);//随系统启动需要转化成.exe文件,jbuilder可生成
jcblistening.addActionListener(this);
jcbmin.addActionListener(this);
}
//控件事件捕获与响应
public void actionPerformed(ActionEvent e){
if(e.getSource()==jbpath)//目录选择功能
{
jtfport.setEnabled(false);
jfcpath.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);//先设置选择的属性
int value=jfcpath.showOpenDialog(this);
if(value==JFileChooser.APPROVE_OPTION)
{
File file=jfcpath.getSelectedFile();
jtfpath.setText(file.getPath());
}
}
if(e.getSource()==jbstart)//启动服务
{
Initialization Ini = new Initialization();
mftp = new MFTP(Ini);
BtnChange(true);
mftp.start();
}
if(e.getSource()==jbstop)//停止服务
{
BtnChange(false);
mftp.stopServer();
mftp = null;
}
if(e.getSource()==jbquit)//退出程序
{
this.dispose();
//this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
if(e.getSource()==jcblistening)//启动监听
{}
if(e.getSource()==jcbmin)//最小化
{}
}
//控件状态
public void BtnChange(bo
没有合适的资源?快使用搜索试试~ 我知道了~
JAVA写的界面形式的服务器程序
共1个文件
java:1个
4星 · 超过85%的资源 需积分: 10 24 下载量 134 浏览量
2010-11-29
19:59:27
上传
评论
收藏 6KB RAR 举报
温馨提示
JAVA服务器程序 JAVA服务器程序 JAVA服务器程序 JAVA服务器程序
资源推荐
资源详情
资源评论
收起资源包目录
JAVA服务器程序.rar (1个子文件)
JFTP.java 25KB
共 1 条
- 1
资源评论
- zfqzfx2013-05-19服务器写的不错哦。。。
- 蓝宝石2012-08-03服务器写的还好 只是没有客户端代码
- phxxk2013-08-16服务器看起来还行
- hanxiaoyeah2013-09-29刚开始学习java,借鉴下
- cxy2013-09-23关于FTP服务器的
sina微博_SNS程飞
- 粉丝: 420
- 资源: 42
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功