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
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Ftp2.5.rar (42个子文件)
Ftp2.5
.project 382B
bin
bashao
view
MainPanel$6.class 2KB
ServerPanel$1.class 2KB
ServerPanel.class 1KB
MainPanel$8.class 670B
MainPanel$RemoteListModel.class 939B
MainPanel$3.class 670B
MainPanel$7.class 2KB
MainPanel$10.class 2KB
MainPanel$2.class 1KB
MainPanel$4.class 2KB
MainPanel$1.class 1KB
LinkPanel.class 4KB
MainPanel$5.class 1KB
MainPanel.class 11KB
MainPanel$11.class 2KB
MainPanel$LocalListModel.class 722B
MainFrame.class 2KB
LinkPanel$1.class 1KB
MainPanel$9.class 1KB
LinkDialog.class 1KB
listener
UpdateComboListListener.class 344B
ftp
ClientMsg.class 760B
FTPServer.class 2KB
FTPClient.class 7KB
ComboListInfo.class 557B
Operation.class 480B
FTPServer$Client.class 8KB
FTPClient$1.class 846B
.settings
org.eclipse.jdt.core.prefs 629B
src
bashao
view
MainFrame.java 1KB
LinkDialog.java 1KB
ServerPanel.java 1KB
MainPanel.java 14KB
LinkPanel.java 3KB
listener
UpdateComboListListener.java 261B
ftp
Operation.java 262B
ClientMsg.java 486B
ComboListInfo.java 330B
FTPServer.java 9KB
FTPClient.java 6KB
.classpath 301B
共 42 条
- 1
bashao4
- 粉丝: 4
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页