云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > Java课程设计-FTP客户端-说明书

Java课程设计-FTP客户端-说明书

  • 62 次阅读
  • 3 次下载
  • 2025/6/14 23:47:21

附录2: 主要源程序

(1) 主界面类Ftp.java

public class Ftp extends JFrame {

FtpBean ftp=new FtpBean(); //FTP客户端对象 private FileWriter write ; private PrintWriter out; private Date time;

private JTextField url = new JTextField(); //FTP服务器地址 private JTextField port = new JTextField(); //FTP服务器端口 private JTextField username = new JTextField(); //用户名 private JTextField password = new JTextField(); //密码 private JTextField status = new JTextField(); //当前状态 private JButton connectButton=new JButton(\连接\); //连接按钮 private JButton closeButton=new JButton(\断开连接\); //断开连接按钮 private JPopupMenu popup = new JPopupMenu();//建立一个弹出式菜单 private JMenuItem refresh = new JMenuItem(\刷新\); //右键弹出菜单 private JMenuItem delete = new JMenuItem(\删除\); private JMenuItem download = new JMenuItem(\下载\); private JMenuItem upload = new JMenuItem(\上传\); private JMenuItem rename = new JMenuItem(\重命名\); private JMenuItem upDir = new JMenuItem(\上级目录\);

private JMenuItem showLog = new JMenuItem(\显示日志信息\);

final DefaultListModel m=new DefaultListModel(); //显示文件列表 JList fileList = new JList(m); //设置一组数组 JScrollPane fileScrollPane;

private Dimension faceSize = new Dimension(400, 400); //框架大小 public Ftp() {

init();

createPopup(); //弹出菜单 time = new Date(); try {

write = new FileWriter(\,true); out = new PrintWriter(write,true); }

catch(IOException ioe) {

ioe.printStackTrace(); }

status.setEditable(false);

this.add(status,BorderLayout.SOUTH); //放置操作信息显示板

connectButton.addActionListener( new ActionListener() {

public void actionPerformed(ActionEvent e) {

connect(); } });

closeButton.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

close();

time = new Date();

out.println(time+\离开服务器:\+url.getText()); } });

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //添加框架的关闭事件处理 this.pack();

this.setSize(faceSize); //设置运行时窗口的位置

Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); this.setLocation( (int) (screenSize.width - faceSize.getWidth()) / 2, (int) (screenSize.height - faceSize.getHeight()) / 2); this.setResizable(false);

this.setTitle(\简单的FTP客户端\); //设置标题 Image i=Toolkit.getDefaultToolkit().getImage(\); this.setIconImage(i); setVisible(true);

this.addWindowListener( //关闭程序时的操作 new WindowAdapter() {

public void windowClosing(WindowEvent e) {

close();

System.exit(0); } }

); }

void init() {

Container contentPane = getContentPane(); //获取面板 contentPane.setLayout(new BorderLayout()); //设置布局

JPanel up = new JPanel(); //设置面板上方控件布局 up.setLayout(new GridLayout(3,2)); url.setText(\); port.setText(\);

username.setText(\);

password.setText(\);

JPanel no1 = new JPanel(); no1.setLayout(new BorderLayout());

no1.add(new JLabel(\服务器:\),BorderLayout.WEST); no1.add(url,BorderLayout.CENTER);

JPanel no2 = new JPanel(); no2.setLayout(new BorderLayout());

no2.add(new JLabel(\端口号:\),BorderLayout.WEST); no2.add(port,BorderLayout.CENTER);

JPanel no3 = new JPanel(); no3.setLayout(new BorderLayout());

no3.add(new JLabel(\用户名:\),BorderLayout.WEST); no3.add(username,BorderLayout.CENTER);

JPanel no4 = new JPanel(); no4.setLayout(new BorderLayout());

no4.add(new JLabel(\密码 :\),BorderLayout.WEST); no4.add(password,BorderLayout.CENTER); up.add(no1); up.add(no2); up.add(no3); up.add(no4);

up.add(connectButton); up.add(closeButton);

closeButton.setEnabled(false);

this.add(up,BorderLayout.NORTH); //上方 fileScrollPane = new JScrollPane(fileList,

JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

fileScrollPane.setPreferredSize(new Dimension(300,400)); this.add(fileScrollPane,BorderLayout.CENTER); //中部 }

void createPopup()

{

refresh.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

update(); } });

popup.add(refresh);

delete.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

deleteFile(); } });

popup.add(delete);

download.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

downloadFile(); } });

popup.add(download);

upload.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

uploadFile(); } });

popup.add(upload);

rename.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

renameFile(); } });

popup.add(rename);

搜索更多关于: Java课程设计-FTP客户端-说明书 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

附录2: 主要源程序 (1) 主界面类Ftp.java public class Ftp extends JFrame { FtpBean ftp=new FtpBean(); //FTP客户端对象 private FileWriter write ; private PrintWriter out; private Date time; private JTextField url = new JTextField(); //FTP服务器地址 private JTextField port = new JTextField(); //FTP服务器端口 private JTextField username = new JTextField(); //用户名 private

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com