package bashao.view;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.util.Vector;
import javax.swing.BorderFactory;
import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.ListModel;
import javax.swing.SwingConstants;
import javax.swing.WindowConstants;
import bashao.ftp.ClientMsg;
import bashao.ftp.ComboListInfo;
import bashao.ftp.FTPServer;
import bashao.listener.UpdateComboListListener;
public class MainPanel extends JPanel implements
UpdateComboListListener{
public static final int FRM_WIDTH=850;
public static final int FRM_HEIGHT=600;
private JButton createDirBtn;
private JButton deleteBtn;
private JButton downloadBtn;
private JButton localPrevBtn;
private JLabel jLabel1;
private JPanel jPanel1;
private JPanel jPanel2;
private JPanel jPanel3;
private JScrollPane jScrollPane1;
private JScrollPane jScrollPane2;
private JComboBox localCombo;
private JLabel localLabel;
private JList localList;
private JComboBox remoteCombo;
public JLabel remoteLabel;
private JList remoteList;
public JProgressBar progressBar;
private JPanel remoteNorthPanel;
private JLabel remoteNorthLabel;
private JTextField remoteNorthTxt;
private JButton remoteNorthSearchBtn;
private JPanel remoteNorthSearchPanel;
public JList getRemoteList() {
return remoteList;
}
private JButton renameBtn;
private JButton uploadBtn;
private JButton prevBtn;
private JButton rootBtn;
private JPanel localSouthPanel;
private JPanel remoteSouthPanel;
private JPanel flowPanel;
private JPanel downloadPanel;
private String localPath;
private String remotePath;
private LocalListModel localListModel=null;
public RemoteListModel remoteListModel=null;
public RemoteListModel getRemoteListModel() {
return remoteListModel;
}
private String localCurrentPath="C:\\";
public String getLocalCurrentPath() {
return localCurrentPath;
}
private String remoteCurrentPath=null;
private String remoteSelectedFile=null;
private String searchFileName=null;
private MainFrame mainFrame=null;
public MainPanel(MainFrame mainFrame){
this.mainFrame=mainFrame;
initComponents();
}
private void initComponents(){
jPanel1=new JPanel();
jLabel1=new JLabel();
jPanel2=new JPanel();
localSouthPanel=new JPanel();
remoteSouthPanel=new JPanel();
flowPanel=new JPanel();
downloadPanel=new JPanel();
uploadBtn=new JButton();
localPrevBtn=new JButton();
localCombo=new JComboBox();
initLocalCombo();
localLabel=new JLabel();
remoteLabel=new JLabel();
jScrollPane1=new JScrollPane();
initLocalListModel();
//localListModel=new LocalListModel();
localList=new JList(localListModel);
//initLocalList();
jPanel3=new JPanel();
downloadBtn=new JButton();
remoteCombo=new JComboBox();
//initRemoteCombo();
jScrollPane2=new JScrollPane();
initRemoteListModel();
//remoteListModel=new RemoteListModel(null);
remoteList=new JList(remoteListModel);
createDirBtn=new JButton();
renameBtn=new JButton();
deleteBtn=new JButton();
prevBtn=new JButton();
rootBtn=new JButton();
//this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
jPanel1.setBorder(BorderFactory.createEtchedBorder());
jLabel1.setText("八勺的FTP 欢迎Q我:592696650,一起探讨java");
jPanel2.setBorder(BorderFactory.createTitledBorder("本地系统"));
jPanel2.setName("1");
uploadBtn.setText("上传");
localPrevBtn.setText("上一层");
localLabel.setText("--------");
localLabel.setBorder(BorderFactory.createEtchedBorder());
jScrollPane1.setViewportView(localList);
jPanel3.setBorder(BorderFactory.createTitledBorder("远程系统"));
downloadBtn.setText("下载");
remoteLabel.setText("-------");
remoteLabel.setBorder(BorderFactory.createEtchedBorder());
jScrollPane2.setViewportView(remoteList);
createDirBtn.setText("创建文件夹");
renameBtn.setText("重命名");
deleteBtn.setText("删除");
prevBtn.setText("上一级");
rootBtn.setText("根目录");
progressBar=new JProgressBar(SwingConstants.HORIZONTAL,1,100);
remoteNorthPanel=new JPanel();
remoteNorthLabel=new JLabel("文件名:");
remoteNorthTxt=new JTextField(25);
remoteNorthSearchBtn=new JButton("搜索");
remoteNorthSearchPanel=new JPanel();
jPanel1.add(jLabel1);
jPanel2.setLayout(new BorderLayout());
jPanel2.add(localCombo,BorderLayout.NORTH);
jPanel2.add(jScrollPane1,BorderLayout.CENTER);
/*localSouthPanel.setLayout(new GridLayout(1,8));
localSouthPanel.add(localLabel,0,7);
localSouthPanel.add(uploadBtn,0,7);*/
//localSouthPanel.setLayout(null);
localSouthPanel.setLayout(new GridLayout(2,1));
//localLabel.setBounds(10,10,200,30);
//uploadBtn.setBounds(260,10,50,30);
//localPrevBtn.setBounds(200,10,50,30);
localSouthPanel.add(localLabel);
//localSouthPanel.add(uploadBtn);
localSouthPanel.add(localPrevBtn);
jPanel2.add(localSouthPanel,BorderLayout.SOUTH);
jPanel3.setLayout(new BorderLayout());
remoteNorthPanel.setLayout(new GridLayout(2,1));
remoteNorthPanel.add(remoteCombo);
remoteNorthSearchPanel.setLayout(new FlowLayout());
remoteNorthSearchPanel.add(remoteNorthLabel);
remoteNorthSearchPanel.add(remoteNorthTxt);
remoteNorthSearchPanel.add(remoteNorthSearchBtn);
remoteNorthPanel.add(remoteNorthSearchPanel);
jPanel3.add(remoteNorthPanel,BorderLayout.NORTH);
jPanel3.add(jScrollPane2,BorderLayout.CENTER);
remoteSouthPanel.setLayout(new GridLayout(3,1));
flowPanel.setLayout(new FlowLayout());
flowPanel.add(createDirBtn);
flowPanel.add(renameBtn);
flowPanel.add(deleteBtn);
flowPanel.add(prevBtn);
flowPanel.add(rootBtn);
remoteSouthPanel.add(flowPanel);
downloadPanel.setLayout(null);
remoteLabel.setBounds(10,0,300,30);
downloadBtn.setBounds(320,0,80,30);
progressBar.setBounds(10,10,400,10);
downloadPanel.add(remoteLabel);
downloadPanel.add(downloadBtn);
remoteSouthPanel.add(downloadPanel);
remoteSouthPanel.add(progressBar);
jPanel3.add(remoteSouthPanel,BorderLayout.SOUTH);
createDirBtn.setEnabled(false);
renameBtn.setEnabled(false);
deleteBtn.setEnabled(false);
remoteNorthSearchBtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
searchFileName=remoteNorthTxt.getText();
if(!searchFileName.equals("")){
ClientMsg msg=new ClientMsg(ClientMsg.CLIENT_MSG_SEARCH,searchFileName);
MainPanel.this.mainFrame.client.sendMsg(msg);
}
}
});
rootBtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
remoteCurrentPath=remoteCurrentPath.substring(0,3);
ClientMsg msg=new ClientMsg(ClientMsg.CLIENT_MSG_LIST,remoteCurrentPath);
MainPanel.this.mainFrame.client.sendMsg(msg);
}
});
localCombo.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
}
});
localCombo.addItemListener(new ItemListener(){
public void itemStateChanged(ItemEvent e) {
File dir=(File) localCombo.getSelectedItem();
localCurrentPath=dir.toString();
File []files=dir.listFiles();
localListModel.removeAllElements();
for(File f:files){
String strFile=f.toString();
localListModel.addElement(strFile);
}
}
});
localList.addMouseListener(new MouseAdapter(){
public void mouseClicked(Mo
java写得FTP文件下载工具源码下载
4星 · 超过85%的资源 需积分: 10 201 浏览量
2010-08-18
14:16:19
上传
评论
收藏 47KB RAR 举报
bashao4
- 粉丝: 4
- 资源: 6
最新资源
- Screenshot_20240427_031602.jpg
- 网页PDF_2024年04月26日 23-46-14_QQ浏览器网页保存_QQ浏览器转格式(6).docx
- 直接插入排序,冒泡排序,直接选择排序.zip
- 在排序2的基础上,再次对快排进行优化,其次增加快排非递归,归并排序,归并排序非递归版.zip
- 实现了7种排序算法.三种复杂度排序.三种nlogn复杂度排序(堆排序,归并排序,快速排序)一种线性复杂度的排序.zip
- 冒泡排序 直接选择排序 直接插入排序 随机快速排序 归并排序 堆排序.zip
- 课设-内部排序算法比较 包括冒泡排序、直接插入排序、简单选择排序、快速排序、希尔排序、归并排序和堆排序.zip
- Python排序算法.zip
- C语言实现直接插入排序、希尔排序、选择排序、冒泡排序、堆排序、快速排序、归并排序、计数排序,并带图详解.zip
- 常用工具集参考用于图像等数据处理
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
前往页