本文为大家介绍了FTP上传下载队列窗口的实现方法,供大家参考,具体内容如下
成都创新互联专注于康乐企业网站建设,响应式网站设计,商城开发。康乐网站建设公司,为康乐等地区提供建站服务。全流程按需设计网站,专业设计,全程项目跟踪,成都创新互联专业和态度为您提供的服务
1、首先看一下队列窗口的界面
2、看一下上传队列窗口的界面
3、看一下下载队列窗口的界面
package com.oyp.ftp.panel.queue;
import static java.awt.BorderLayout.CENTER;
import static java.awt.BorderLayout.EAST;
import static javax.swing.ListSelectionModel.SINGLE_SELECTION;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import java.util.LinkedList;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JToggleButton;
import javax.swing.JToolBar;
import javax.swing.ListSelectionModel;
import javax.swing.Timer;
import javax.swing.table.DefaultTableModel;
import com.oyp.ftp.FTPClientFrame;
import com.oyp.ftp.utils.FtpClient;
import com.oyp.ftp.utils.FtpFile;
/**
* 任务队列控制面板
*/
public class QueuePanel extends JPanel implements ActionListener {
private JTable queueTable = new JTable(); // 显示任务队列的表格组件
private JScrollPane scrollPane = new JScrollPane();
private FTPClientFrame frame; // 主窗体的引用对象
private String[] columns;
private FtpClient ftpClient; // FTP协议的控制类
private Timer queueTimer; // 队列的定时器
private LinkedList
5.上传队列窗口的实现
package com.oyp.ftp.panel.queue;
import java.awt.CardLayout;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;
import com.oyp.ftp.panel.QueueTableCellRanderer;
import com.oyp.ftp.utils.ProgressArg;
public class UploadPanel extends JPanel {
private JTable uploadTable = new JTable(); // 表格组件
private JScrollPane scrollPane = new JScrollPane();
private DefaultTableModel model; // 表格的数据模型
/**
* 构造方法,用于初始化程序界面
*/
public UploadPanel() {
CardLayout cardLayout = new CardLayout();
setLayout(cardLayout);
ProgressArg progressArg = new ProgressArg(-1, -1, -1);
model = new DefaultTableModel(new Object[][] { new Object[] { "", "",
"", "", progressArg } }, new String[] { "文件名", "大小", "远程文件名",
"主机", "状态" });
uploadTable.setModel(model);
uploadTable.getTableHeader().setReorderingAllowed(false);
uploadTable.setRowSelectionAllowed(false);
TableColumn column = uploadTable.getColumn("状态");
column.setCellRenderer(new QueueTableCellRanderer());
scrollPane.setViewportView(uploadTable);
cardLayout.layoutContainer(scrollPane);
add(scrollPane, "queue");
}
/**
* 向上传队列的表格组件添加新任务的方法
*
* @param values
* - 添加到表格的一行数据的数组对象
*/
public void addRow(final Object[] values) {
Runnable runnable = new Runnable() {
public void run() {
model.insertRow(0, values); // 向表格的数据模型添加数据
}
};
if (SwingUtilities.isEventDispatchThread())
runnable.run(); // 在事件队列执行
else
SwingUtilities.invokeLater(runnable); // 或有事件队列调用
}
}
6.下载队列窗口的实现
package com.oyp.ftp.panel.queue;
import java.awt.CardLayout;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;
import com.oyp.ftp.panel.QueueTableCellRanderer;
import com.oyp.ftp.utils.ProgressArg;
public class DownloadPanel extends JPanel {
private JTable downloadTable = new JTable();
private JScrollPane scrollPane = new JScrollPane();
private DefaultTableModel model;
public DownloadPanel() {
CardLayout cardLayout = new CardLayout();
setLayout(cardLayout);
ProgressArg progressArg = new ProgressArg(-1, -1, -1);
model = new DefaultTableModel(new Object[][] { new Object[] { "", "",
"", "", progressArg } }, new String[] { "文件名", "大小", "本地文件名",
"主机", "状态" });
downloadTable.setModel(model);
downloadTable.getTableHeader().setReorderingAllowed(false);
downloadTable.setRowSelectionAllowed(false);
TableColumn column = downloadTable.getColumn("状态");
column.setCellRenderer(new QueueTableCellRanderer());
scrollPane.setViewportView(downloadTable);
cardLayout.layoutContainer(scrollPane);
add(scrollPane, "queue");
}
public void addRow(final Object[] values) {
Runnable runnable = new Runnable() {
public void run() {
model.insertRow(0, values);
}
};
if (SwingUtilities.isEventDispatchThread())
runnable.run();
else
SwingUtilities.invokeLater(runnable);
}
}
下面窗口具体的上传下载后的变化
1.上传任务的添加
2.上传任务的完成
3.下载任务的添加
4.下载任务的完成
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持创新互联。
文章题目:Java语言实现简单FTP软件FTP上传下载队列窗口实现(7)
网页链接:
http://6mz.cn/article/gggiii.html