diff --git a/out/production/ftpsystem/ftp/UI.class b/out/production/ftpsystem/ftp/UI.class index 9ab93c12c51b8ad5a0cc46832a8d304bef548bb7..23c4677207949ce28cae2ee81466f5b0d86180a5 100644 Binary files a/out/production/ftpsystem/ftp/UI.class and b/out/production/ftpsystem/ftp/UI.class differ diff --git a/src/ftp/FtpPanel.java b/src/ftp/FtpPanel.java index f15b5d2ed9c22f63e3801c3d72758a46241fbdcf..5d8ac47d2c4b0a56b5cf472e02b2133bfc4c547f 100644 --- a/src/ftp/FtpPanel.java +++ b/src/ftp/FtpPanel.java @@ -1,4 +1,174 @@ package ftp; -public class FtpPanel { +import javax.swing.*; +import javax.swing.table.DefaultTableModel; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.text.SimpleDateFormat; +import java.util.List; + +import static ftp.Global.ftpClient; + +/** + * 实现本地文件浏览,为继承JPanel的一个面板 + * + * @author Lonsy + * @version 1.0 + */ +public class FtpPanel extends JPanel implements ActionListener, MouseListener +{ + private JButton jbUp; + private JComboBox jcbPath; + private JTable jtFile; + private DefaultTableModel dtmFile; + private JLabel jlLocal; + private Fileinfo path; + private boolean init; + private String currentPath; + private int currentIndex; + List list; + + + private String file1 = new String(); + + public FtpPanel() { + super ( new BorderLayout()); + + JPanel jp = new JPanel( new BorderLayout()); + jbUp = new JButton( " up " ); + jbUp.addActionListener( this ); + jcbPath = new JComboBox(); + jcbPath.addActionListener( this ); + jp.add(jbUp, BorderLayout.WEST); + jp.add(jcbPath, BorderLayout.CENTER ); + dtmFile = new LocalTableModel(); + dtmFile.addColumn( " 名称 " ); + dtmFile.addColumn( " 大小 " ); + dtmFile.addColumn( " 类型 " ); + dtmFile.addColumn( " 修改日期 " ); + jtFile = new JTable(dtmFile); + jtFile.setShowGrid( false ); + jtFile.addMouseListener( this ); + jlLocal = new JLabel( " / " , JLabel.CENTER); + + add(jp, BorderLayout.NORTH ); + add( new JScrollPane(jtFile), BorderLayout.CENTER); + add(jlLocal, BorderLayout.SOUTH); + + // 显示系统分区及文件路径 并 在JTabel中显示当前路径的文件信息 + + currentPath = "/"; + List list=FileView.viewFile(ftpClient); + listFiles(); + + + } + public String getCurrentPath() { + return currentPath; + } + private boolean listFiles() { + list=FileView.viewFile(ftpClient); + dtmFile.setRowCount( 0 ); + if(list.size()>0){ + for(int i=1;i