package com.exercise.view;
import com.exercise.model.bean.FileBean;
import com.exercise.view.components.MyListCellRender;
import com.exercise.controller.Controller;
import com.exercise.model.Model;
import com.exercise.model.bean.FtpInfoBean;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.JOptionPane;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.plaf.basic.BasicListUI.ListSelectionHandler;
/*
* 作者:胡荆陵
* 说明:程序主Frame
* 其中包括: 本地文件列表面板 LeftPanel, 服务器文件列表面板 RightPanel,
* 输出框 TextArer, 用户登陆框 LoginRemoteDialog
*/
public class MainFrame extends javax.swing.JFrame {
private Model model;
private Controller controller;
public MainFrame(Model model, Controller controller) {
this.model = model;
this.controller = controller;
initComponents();
initListener();
initData();
setLocationRelativeTo(null);
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
loginRemoteDialog1 = new com.exercise.view.LoginRemoteDialog();
jScrollPane1 = new javax.swing.JScrollPane();
logTextArea = new javax.swing.JTextArea();
localFilePanel = new com.exercise.view.LeftPanel();
remoteFilePanel = new com.exercise.view.RightPanel();
jLabel1 = new javax.swing.JLabel();
logClearButton = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("FTP客户端演示");
logTextArea.setColumns(20);
logTextArea.setEditable(false);
logTextArea.setRows(5);
jScrollPane1.setViewportView(logTextArea);
jLabel1.setText("操作记录:");
logClearButton.setText("清除记录");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 716, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(localFilePanel, javax.swing.GroupLayout.DEFAULT_SIZE, 354, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(remoteFilePanel, javax.swing.GroupLayout.DEFAULT_SIZE, 352, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 581, Short.MAX_VALUE)
.addComponent(logClearButton)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(remoteFilePanel, javax.swing.GroupLayout.DEFAULT_SIZE, 306, Short.MAX_VALUE)
.addComponent(localFilePanel, javax.swing.GroupLayout.DEFAULT_SIZE, 306, Short.MAX_VALUE))
.addGap(11, 11, 11)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(logClearButton))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 66, Short.MAX_VALUE)
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel jLabel1;
private javax.swing.JScrollPane jScrollPane1;
private com.exercise.view.LeftPanel localFilePanel;
private javax.swing.JButton logClearButton;
private javax.swing.JTextArea logTextArea;
private com.exercise.view.LoginRemoteDialog loginRemoteDialog1;
private com.exercise.view.RightPanel remoteFilePanel;
// End of variables declaration//GEN-END:variables
//数据初始化
private void initData() {
//设置自定义cellRender类
localFilePanel.getLocalFileList().setCellRenderer(new MyListCellRender());
remoteFilePanel.getRemoteFileList().setCellRenderer(new MyListCellRender());
//初始化 JList 数据
controller.refreshLocalFiles(null);
controller.initRemoteFiles();
}
//初始化 Listener
private void initListener() {
//监听模型类的属性变化,做相应视图更新
this.model.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals("localFiles")) {
//更新本地文件列表
localFilePanel.getLocalFileList().setListData(model.getLocalFiles());
} else if (evt.getPropertyName().equals("localPath")) {
//更新本地文件路径
localFilePanel.getLocalPathText().setText(model.getLocalPath());
} else if (evt.getPropertyName().equals("remoteFiles")) {
//更新服务器文件列表
remoteFilePanel.getRemoteFileList().setListData(model.getRemoteFiles());
} else if (evt.getPropertyName().equals("remotePath")) {
remoteFilePanel.getRemotePathText().setText(model.getRemotePath());
} else if (evt.getPropertyName().equals("lastLogInfo")) {
String oldValue = logTextArea.getText();
logTextArea.setText(oldValue + model.getLastLogInfo() + "\n");
}
}
});
//本地文件向上按钮
localFilePanel.getLocalUpperButton().addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
controller.localUpperButtonClickHandler();//路径向上
}
});
//本地文件 JList 鼠标双击的事件处理方法
localFilePanel.getLocalFileList().addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
FileBean fb = (FileBean) localFilePanel.getLocalFileList().getSelectedValue();
if (fb.getType().equals(FileBean.FileType.file)) {
if (model.isUploadNeedConfirm()) {
//弹出框确认操作
int result = JOptionPane.showConfirmDia
没有合适的资源?快使用搜索试试~ 我知道了~
上传文件到ftp服务器工具
共120个文件
html:87个
java:14个
xml:4个
4星 · 超过85%的资源 需积分: 10 9 下载量 131 浏览量
2012-08-20
17:19:37
上传
评论
收藏 244KB ZIP 举报
温馨提示
用swing做的前台页面,能选择文件上传到ftp服务器,一个简单的上传文件工具
资源推荐
资源详情
资源评论
收起资源包目录
上传文件到ftp服务器工具 (120个子文件)
stylesheet.css 1KB
RightPanel.form 8KB
LeftPanel.form 6KB
MainFrame.form 5KB
swing_mvc.gif 6KB
inherit.gif 57B
RightPanel.html 25KB
LoginRemoteDialog.html 25KB
MyListCellRender.html 24KB
TestCellRender.html 24KB
MainFrame.html 23KB
LeftPanel.html 23KB
FtpUtil.html 19KB
Model.html 18KB
FileBean.html 18KB
Controller.html 17KB
FileBean.html 17KB
FtpInfoBean.html 16KB
index-5.html 15KB
serialized-form.html 15KB
FileBean.FileType.html 14KB
FtpInfoBean.html 13KB
index-12.html 11KB
StringUtil.html 10KB
package-use.html 10KB
FileBean.FileType.html 10KB
FileUtil.html 10KB
help-doc.html 9KB
overview-tree.html 9KB
FtpClientDemo.html 9KB
index-4.html 9KB
Model.html 9KB
index-8.html 8KB
index-11.html 8KB
index-2.html 8KB
index-6.html 8KB
Controller.html 8KB
index-7.html 8KB
index-3.html 8KB
package-use.html 7KB
package-tree.html 7KB
index-13.html 7KB
package-summary.html 7KB
index-14.html 7KB
index-15.html 7KB
package-summary.html 7KB
package-summary.html 7KB
package-tree.html 7KB
package-use.html 7KB
overview-summary.html 7KB
package-tree.html 7KB
package-tree.html 7KB
index-10.html 7KB
package-tree.html 7KB
index-9.html 6KB
index-1.html 6KB
package-summary.html 6KB
package-summary.html 6KB
package-summary.html 6KB
package-summary.html 6KB
package-tree.html 6KB
MyListCellRender.html 6KB
package-tree.html 6KB
StringUtil.html 6KB
FileUtil.html 6KB
FtpUtil.html 6KB
package-summary.html 6KB
LoginRemoteDialog.html 6KB
TestCellRender.html 6KB
RightPanel.html 6KB
MainFrame.html 6KB
LeftPanel.html 6KB
package-tree.html 6KB
FtpClientDemo.html 6KB
package-use.html 6KB
package-use.html 6KB
package-use.html 6KB
package-use.html 6KB
package-use.html 5KB
constant-values.html 5KB
deprecated-list.html 5KB
allclasses-frame.html 3KB
allclasses-noframe.html 2KB
overview-frame.html 2KB
index.html 1KB
package-frame.html 1KB
package-frame.html 1KB
package-frame.html 1KB
package-frame.html 1012B
package-frame.html 974B
package-frame.html 958B
package-frame.html 944B
package-frame.html 930B
FtpClient.jar 85KB
MainFrame.java 15KB
FtpUtil.java 9KB
Controller.java 8KB
RightPanel.java 8KB
LeftPanel.java 6KB
LoginRemoteDialog.java 4KB
共 120 条
- 1
- 2
资源评论
- a18942337162013-10-06很好,很强大,不过对也我这初学者来说要学习一会了
pinkpqs
- 粉丝: 1
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功