FTP客户端的设计实现代码.docx

上传人:b****5 文档编号:11853750 上传时间:2023-04-06 格式:DOCX 页数:35 大小:24.62KB
下载 相关 举报
FTP客户端的设计实现代码.docx_第1页
第1页 / 共35页
FTP客户端的设计实现代码.docx_第2页
第2页 / 共35页
FTP客户端的设计实现代码.docx_第3页
第3页 / 共35页
FTP客户端的设计实现代码.docx_第4页
第4页 / 共35页
FTP客户端的设计实现代码.docx_第5页
第5页 / 共35页
点击查看更多>>
下载资源
资源描述

FTP客户端的设计实现代码.docx

《FTP客户端的设计实现代码.docx》由会员分享,可在线阅读,更多相关《FTP客户端的设计实现代码.docx(35页珍藏版)》请在冰豆网上搜索。

FTP客户端的设计实现代码.docx

FTP客户端的设计实现代码

importjavax.swing.*;

importjava.awt.Rectangle;

importjava.io.*;

import.*;

importjava.util.*;

publicclassccFtpextendsJFrame{

privatestaticfinallongserialVersionUID=1L;

privateJPaneljContentPane=null;

privateJButtonjButtonLocalRefresh=null;

privateJButtonjButtonLocalMKDIR=null;

privateJButtonjButtonLocalRename=null;

privateJButtonjButtonLocalDelete=null;

privateJButtonjButtonServerRefresh=null;

privateJButtonjButtonServerMKDIR=null;

privateJButtonjButtonServerRename=null;

privateJButtonjButtonServerDelete=null;

privateJScrollPanejScrollPaneLocal=null;

privateJScrollPanejScrollPaneServer=null;

privateJButtonjButtonUpload=null;

privateJButtonjButtonDownload=null;

privateJLabeljLabelSeverAdd=null;

privateJLabeljLabelPort=null;

privateJLabeljLabelUserName=null;

privateJLabeljLabelPassword=null;

privateJTextFieldjTextFieldServerAdd=null;

privateJTextFieldjTextFieldPort=null;

privateJTextFieldjTextFieldUserName=null;

privateJTextFieldjTextFieldPassword=null;

privateJButtonjButtonConnect=null;

privateJButtonjButtonDisconnect=null;

privateJButtonjButtonExit=null;

privateJScrollPanejScrollPaneTextArea=null;

privateJListjListLocalFile=null;

privateDefaultListModellistLocalFile;

privateJListjListServerFile=null;

privateDefaultListModellistServerFile;

privateJTextAreajTextAreaStatus=null;

privateJProgressBarjProgressBar=null;

privateJScrollPanejScrollPaneDownload=null;

privateJListjListDownloadMonitor=null;

privateDefaultListModellistitemThing;

privateBufferedReaderreader=null;//@jve:

decl-index=0:

privateBufferedWriterwriter=null;

privateJRadioButtonjRadioButtonPORT=null;

privateJRadioButtonjRadioButtonPASV=null;

privateJLabeljLabelMode=null;

longclickTime=0;

StringgetPASVip;

Stringip=null;//@jve:

decl-index=0:

intport=-1;

Stringcmdline;

StringjListDriveName="D:

\\";//@jve:

decl-index=0:

privateJButtongetJButtonLocalRefresh(){//刷新按钮的功能

if(jButtonLocalRefresh==null){

jButtonLocalRefresh=newJButton();

jButtonLocalRefresh.setBounds(newRectangle(8,13,85,26));

jButtonLocalRefresh.setText("刷新");

jButtonLocalRefresh.addActionListener(

newjava.awt.event.ActionListener(){

publicvoidactionPerformed(java.awt.event.ActionEvente){

listLocalFile.clear();

ListFile();

}

}

);

}

returnjButtonLocalRefresh;

}

privateJButtongetJButtonLocalMKDIR(){//新建文件夹的功能

if(jButtonLocalMKDIR==null){

jButtonLocalMKDIR=newJButton();

jButtonLocalMKDIR.setBounds(newRectangle(8,46,85,26));

jButtonLocalMKDIR.setText("新建文件夹");

jButtonLocalMKDIR.addActionListener(newjava.awt.event.ActionListener(){

publicvoidactionPerformed(java.awt.event.ActionEvente){

StringFloderName=JOptionPane.showInputDialog("NewFloderName:

");

if(FloderName!

=null)

{

Filefile=newFile(jListDriveName+FloderName);

file.mkdir();

listLocalFile.clear();

ListFile();

}

}

});

}

returnjButtonLocalMKDIR;

}

privateJButtongetJButtonLocalRename(){

if(jButtonLocalRename==null){

jButtonLocalRename=newJButton();

jButtonLocalRename.setBounds(newRectangle(8,78,85,26));

jButtonLocalRename.setText("重命名");

jButtonLocalRename.addActionListener(newjava.awt.event.ActionListener(){

publicvoidactionPerformed(java.awt.event.ActionEvente){

Stringoldname=jListLocalFile.getSelectedValue().toString();

if(oldname.substring(oldname.length()-1).equalsIgnoreCase("\\"))

{

oldname=oldname.substring(0,oldname.length()-1);

}

Fileoldf=newFile(jListDriveName+oldname);

Stringnewname=JOptionPane.showInputDialog("NewName:

");

if(newname!

=null)

{

Filenewf=newFile(jListDriveName+newname);

oldf.renameTo(newf);

}

listLocalFile.clear();

ListFile();

}

});

}

returnjButtonLocalRename;

}

privateJButtongetJButtonLocalDelete(){

if(jButtonLocalDelete==null){

jButtonLocalDelete=newJButton();

jButtonLocalDelete.setBounds(newRectangle(8,111,85,26));

jButtonLocalDelete.setText("删除");

jButtonLocalDelete.addActionListener(newjava.awt.event.ActionListener(){

publicvoidactionPerformed(java.awt.event.ActionEvente){

Stringname=jListLocalFile.getSelectedValue().toString();

if(name.substring(name.length()-1).equalsIgnoreCase("\\"))

{

name=name.substring(0,name.length()-1);

}

Filedel=newFile(jListDriveName+name);

del.delete();

listLocalFile.clear();

ListFile();

}

});

}

returnjButtonLocalDelete;

}

privateJButtongetJButtonServerRefresh(){

if(jButtonServerRefresh==null){

jButtonServerRefresh=newJButton();

jButtonServerRefresh.setBounds(newRectangle(628,13,82,26));

jButtonServerRefresh.setText("刷新");

jButtonServerRefresh.addActionListener(newjava.awt.event.ActionListener(){

publicvoidactionPerformed(java.awt.event.ActionEvente){

try{

lsCurrentDir();

}catch(Exceptione1){

e1.printStackTrace();

}

}

});

}

returnjButtonServerRefresh;

}

privateJButtongetJButtonServerMKDIR(){

if(jButtonServerMKDIR==null){

jButtonServerMKDIR=newJButton();

jButtonServerMKDIR.setBounds(newRectangle(628,46,82,26));

jButtonServerMKDIR.setText("新建目录");

jButtonServerMKDIR.addActionListener(newjava.awt.event.ActionListener(){

publicvoidactionPerformed(java.awt.event.ActionEvente){

StringFloderName=JOptionPane.showInputDialog("NewFloderName:

");

if(FloderName!

=null)

{

try{

writer.write("MKD"+FloderName+"\r\n");

writer.flush();

cmdline=reader.readLine();

jTextAreaStatus.append(cmdline+"\n");

lsCurrentDir();

}catch(Exceptione1){

e1.printStackTrace();

}

}

}

});

}

returnjButtonServerMKDIR;

}

privateJButtongetJButtonServerRename(){

if(jButtonServerRename==null){

jButtonServerRename=newJButton();

jButtonServerRename.setBounds(newRectangle(628,78,82,26));

jButtonServerRename.setText("删除文件");

jButtonServerRename.addActionListener(newjava.awt.event.ActionListener(){

publicvoidactionPerformed(java.awt.event.ActionEvente){

}

});

}

returnjButtonServerRename;

}

privateJButtongetJButtonServerDelete(){

if(jButtonServerDelete==null){

jButtonServerDelete=newJButton();

jButtonServerDelete.setBounds(newRectangle(628,111,82,26));

jButtonServerDelete.setText("删除目录");

}

returnjButtonServerDelete;

}

privateJScrollPanegetJScrollPaneLocal(){

if(jScrollPaneLocal==null){

jScrollPaneLocal=newJScrollPane();

jScrollPaneLocal.setBounds(newRectangle(104,13,228,320));

jScrollPaneLocal.setViewportView(getJListLocalFile());

}

returnjScrollPaneLocal;

}

privateJScrollPanegetJScrollPaneServer(){

if(jScrollPaneServer==null){

jScrollPaneServer=newJScrollPane();

jScrollPaneServer.setBounds(newRectangle(391,13,229,319));

jScrollPaneServer.setViewportView(getJListServerFile());

}

returnjScrollPaneServer;

}

privateJButtongetJButtonUpload(){

if(jButtonUpload==null){

jButtonUpload=newJButton();

jButtonUpload.setBounds(newRectangle(340,115,60,30));

jButtonUpload.setText("上传");

jButtonUpload.addActionListener(newjava.awt.event.ActionListener(){

publicvoidactionPerformed(java.awt.event.ActionEvente){

UploadArray();

}

});

}

returnjButtonUpload;

}

protectedvoidDownloadArray(){

StringLindex,Rfile;

intLfliename=jListServerFile.getSelectedValue().toString().length();

Lindex=jListServerFile.getSelectedValue().toString().substring(Lfliename-1);

Rfile=jListServerFile.getSelectedValue().toString().substring(0,Lfliename-1);

if(Lindex.equalsIgnoreCase("\\"))

{

JOptionPane.showMessageDialog(null,"Thisisnotafile..ConnotbeUploaded!

","ERROR",JOptionPane.ERROR_MESSAGE);

}

else{

listitemThing.insertElementAt("Dload..."+Rfile,jListDownloadMonitor.getLastVisibleIndex()+1);

jListDownloadMonitor.setSelectedIndex(jListDownloadMonitor.getFirstVisibleIndex());

}

}

privateJButtongetJButtonDownload(){

if(jButtonDownload==null){

jButtonDownload=newJButton();

jButtonDownload.setBounds(newRectangle(340,156,60,30));

jButtonDownload.setText("下载");

jButtonDownload.addActionListener(newjava.awt.event.ActionListener(){

publicvoidactionPerformed(java.awt.event.ActionEvente){

DownloadArray();

}

});

}

returnjButtonDownload;

}

protectedvoidUploadArray(){

Filedirectory=newFile(jListDriveName+jListLocalFile.getSelectedValue());

if(directory.isFile())

{

listitemThing.insertElementAt("Uload..."+jListLocalFile.getSelectedValue(),jListDownloadMonitor.getLastVisibleIndex()+1);

jListDownloadMonitor.setSelectedIndex(jListDownloadMonitor.getFirstVisibleIndex());

}

else

JOptionPane.showMessageDialog(null,"ThisisnotaFile!

","ERROR",JOptionPane.ERROR_MESSAGE);

}

privateJTextFieldgetJTextFieldServerAdd(){

if(jTextFieldServerAdd==null){

jTextFieldServerAdd=newJTextField();

jTextFieldServerAdd.setBounds(newRectangle(121,339,119,20));

jTextFieldServerAdd.setText("127.0.0.1");

}

returnjTextFieldServerAdd;

}

privateJTextFieldgetJTextFieldPort(){

if(jTextFieldPort==null){

jTextFieldPort=newJTextField();

jTextFieldPort.setBounds(newRectangle(121,362,119

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 解决方案 > 其它

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1