搜尋
首頁Javajava教程Java語言實作簡單FTP軟體-FTP軟體主介面的程式碼詳解(四)

這篇文章主要為大家詳細介紹了Java語言實作簡單FTP軟體,FTP軟體主介面寫的方法,具有一定的參考價值,有興趣的夥伴們可以參考一下

首先看一下FTP軟體的整體程式碼框架,具體內容如下

Java語言實作簡單FTP軟體-FTP軟體主介面的程式碼詳解(四)Java語言實作簡單FTP軟體-FTP軟體主介面的程式碼詳解(四)

#1、先介紹程式的主入口FTPMain.java,採用了一個漂亮的外觀風格

package com.oyp.ftp; 
 
import java.util.logging.Level; 
import java.util.logging.Logger; 
 
import javax.swing.UIManager; 
 
import com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel; 
 
public class FTPMain { 
 /** 
  * 本应用的程序入口 
  */ 
 public static void main(String args[]) { 
  //导致 runnable 的 run 方法在 EventQueue 的指派线程上被调用。 
  java.awt.EventQueue.invokeLater(new Runnable() { 
   public void run() { 
    try { 
     //使用 LookAndFeel 对象设置当前的默认外观。 
     UIManager.setLookAndFeel(new NimbusLookAndFeel());//设置一个非常漂亮的外观 
//     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 
     FTPClientFrame client_Frame = new FTPClientFrame(); 
     client_Frame.setVisible(true); 
    } catch (Exception ex) { 
     Logger.getLogger(FTPClientFrame.class.getName()).log( 
       Level.SEVERE, null, ex); 
    } 
   } 
  }); 
 } 
}

 2、介紹介面的主程式碼FTPClientFrame.java

package com.oyp.ftp; 
 
import java.awt.AWTException; 
import java.awt.MenuItem; 
import java.awt.PopupMenu; 
import java.awt.SystemTray; 
import java.awt.TrayIcon; 
import java.awt.event.ActionEvent; 
import java.awt.event.ActionListener; 
import java.awt.event.WindowEvent; 
 
import javax.swing.ImageIcon; 
import javax.swing.JButton; 
import javax.swing.JFrame; 
import javax.swing.JLabel; 
import javax.swing.JMenu; 
import javax.swing.JMenuBar; 
import javax.swing.JMenuItem; 
import javax.swing.JPanel; 
import javax.swing.JPasswordField; 
import javax.swing.JSeparator; 
import javax.swing.JSplitPane; 
import javax.swing.JTabbedPane; 
import javax.swing.JTextField; 
import javax.swing.JToggleButton; 
import javax.swing.JToolBar; 
import javax.swing.UIManager; 
 
import com.oyp.ftp.panel.ftp.FtpPanel; 
import com.oyp.ftp.panel.local.LocalPanel; 
import com.oyp.ftp.panel.manager.FtpSiteDialog; 
import com.oyp.ftp.panel.queue.DownloadPanel; 
import com.oyp.ftp.panel.queue.QueuePanel; 
import com.oyp.ftp.panel.queue.UploadPanel; 
import com.oyp.ftp.utils.FtpClient; 
import com.oyp.ftp.utils.SiteInfoBean; 
import com.sun.java.swing.plaf.nimbus.*; 
 
public class FTPClientFrame extends javax.swing.JFrame { 
 FtpClient ftpClient; 
 private JPasswordField PassField; 
 private JButton cutLinkButton; 
 FtpPanel ftpPanel; 
 LocalPanel localPanel; 
 private JTextField portTextField; 
 private JTextField serverTextField; 
 private JTextField userTextField; 
 private QueuePanel queuePanel; 
 private UploadPanel uploadPanel; 
 private DownloadPanel downloadPanel; 
 private JSplitPane jSplitPane1; 
 private JButton linkButton; 
 private final LinkToAction LINK_TO_ACTION; // 连接到 按钮的动作处理器 
 private final CutLinkAction CUT_LINK_ACTION; // 断开 按钮的动作处理器 
 private SystemTray systemTray; 
 private JToggleButton shutdownButton; 
 private final ImageIcon icon = new ImageIcon(getClass().getResource( 
   "/com/oyp/ftp/res/trayIcon.png")); 
 
 public FTPClientFrame() { 
  LINK_TO_ACTION = new LinkToAction(this, "连接到", null); 
  CUT_LINK_ACTION = new CutLinkAction(this, "断开", null); 
  initComponents(); 
  initSystemTray(); 
 } 
 
 /** 
  * 初始化系统托盘的方法 
  */ 
 private void initSystemTray() { 
  if (SystemTray.isSupported()) 
   systemTray = SystemTray.getSystemTray(); 
  TrayIcon trayIcon = new TrayIcon(icon.getImage()); 
  PopupMenu popupMenu = new PopupMenu("托盘菜单"); 
 
  // 创建显示主窗体菜单项 
  MenuItem showMenuItem = new MenuItem("显示主窗体"); 
  showMenuItem.addActionListener(new ActionListener() { 
   @Override 
   public void actionPerformed(ActionEvent e) { 
    FTPClientFrame.this.setExtendedState(JFrame.NORMAL); 
    FTPClientFrame.this.setVisible(true); 
   } 
  }); 
 
  // 创建退出菜单项 
  MenuItem exitMenuItem = new MenuItem("退出"); 
  exitMenuItem.addActionListener(new ActionListener() { 
   @Override 
   public void actionPerformed(ActionEvent e) { 
    System.exit(0); 
   } 
  }); 
 
  popupMenu.add(showMenuItem); 
  popupMenu.addSeparator(); 
  popupMenu.add(exitMenuItem); 
  trayIcon.setPopupMenu(popupMenu); 
  try { 
   systemTray.add(trayIcon); 
  } catch (AWTException e) { 
   e.printStackTrace(); 
  } 
 } 
 
 /** 
  * 初始化程序界面的方法 
  */ 
 private void initComponents() { 
  setIconImage(icon.getImage()); 
  java.awt.GridBagConstraints gridBagConstraints; 
 
  JPanel jPanel1 = new JPanel(); 
  JToolBar jToolBar1 = new JToolBar(); 
  JButton linkTo = new JButton(); 
  cutLinkButton = new JButton(); 
  JPanel jPanel4 = new JPanel(); 
  JLabel jLabel1 = new JLabel(); 
  serverTextField = new JTextField(); 
  JLabel jLabel2 = new JLabel(); 
  userTextField = new JTextField(); 
  JLabel jLabel3 = new JLabel(); 
  PassField = new JPasswordField(); 
  JLabel jLabel6 = new JLabel(); 
  portTextField = new JTextField(); 
  linkButton = new JButton(); 
  JSplitPane jSplitPane2 = new JSplitPane(); 
  jSplitPane1 = new JSplitPane(); 
  ftpPanel = new FtpPanel(this); // 初始化FTP远程资源面板 
  localPanel = new LocalPanel(this); // 初始化本地资源管理面板 
  uploadPanel = new UploadPanel(); // 初始化上传队列面板 
  downloadPanel = new DownloadPanel(); // 初始化下载队列面板 
  queuePanel = new QueuePanel(this); // 初始化队列面板 
 
  JTabbedPane jTabbedPane1 = new JTabbedPane(); 
  JMenuBar MenuBar = new JMenuBar(); 
  JMenu fileMenu = new JMenu(); 
  JMenuItem ftpManageMenuItem = new JMenuItem(); 
  JSeparator jSeparator1 = new JSeparator(); 
  JMenuItem linkToMenuItem = new javax.swing.JMenuItem(); 
  JMenuItem cutMenuItem = new javax.swing.JMenuItem(); 
  JSeparator jSeparator2 = new javax.swing.JSeparator(); 
  JMenuItem exitMenuItem = new javax.swing.JMenuItem(); 
  JMenuItem uploadMenuItem = new javax.swing.JMenuItem(); 
  JSeparator jSeparator3 = new javax.swing.JSeparator(); 
  JMenuItem createFolderMenuItem = new javax.swing.JMenuItem(); 
  JMenuItem renameMenuItem = new javax.swing.JMenuItem(); 
  JMenuItem delMenuItem = new javax.swing.JMenuItem(); 
  JMenu ftpMenu = new javax.swing.JMenu(); 
  JMenuItem downMenuItem = new javax.swing.JMenuItem(); 
  JSeparator jSeparator6 = new javax.swing.JSeparator(); 
  JMenuItem ftpDelMenuItem = new javax.swing.JMenuItem(); 
  JMenuItem ftpRenameMenuItem = new javax.swing.JMenuItem(); 
  JMenuItem newFolderMenuItem = new javax.swing.JMenuItem(); 
  JMenu helpMenu = new javax.swing.JMenu(); 
  JMenuItem aboutMenuItem = new javax.swing.JMenuItem(); 
  JMenuItem bugMenuItem = new javax.swing.JMenuItem(); 
 
//  setTitle("基于Socket的FTP软件Java实现"); 
  setTitle("Java语言实现简单FTP软件欧阳鹏设计"); 
  addWindowListener(new java.awt.event.WindowAdapter() { 
   public void windowOpened(java.awt.event.WindowEvent evt) { 
    formWindowOpened(evt); 
   } 
 
   public void windowIconified(final WindowEvent e) { 
    setVisible(false); 
   } 
  }); 
  addComponentListener(new java.awt.event.ComponentAdapter() { 
   public void componentResized(java.awt.event.ComponentEvent evt) { 
    formComponentResized(evt); 
   } 
  }); 
  getContentPane().setLayout(new java.awt.GridBagLayout()); 
 
  jPanel1.setLayout(new java.awt.GridLayout(0, 1)); 
 
  jToolBar1.setRollover(true); 
  jToolBar1.setFloatable(false); 
 
  linkTo.setText("连接到"); 
  linkTo.setFocusable(false); 
  linkTo.setAction(LINK_TO_ACTION); 
  jToolBar1.add(linkTo); 
 
  cutLinkButton.setText("断开"); 
  cutLinkButton.setEnabled(false); 
  cutLinkButton.setFocusable(false); 
  cutLinkButton.setAction(CUT_LINK_ACTION); 
  jToolBar1.add(cutLinkButton); 
 
  jPanel1.add(jToolBar1); 
   
  shutdownButton = new JToggleButton(); 
  shutdownButton.setText("自动关机"); 
  shutdownButton.setToolTipText("队列完成后,自动关闭计算机"); 
  shutdownButton.setFocusable(false); 
  jToolBar1.add(shutdownButton); 
 
  jPanel4.setBorder(javax.swing.BorderFactory.createEtchedBorder()); 
  jPanel4.setLayout(new javax.swing.BoxLayout(jPanel4, 
    javax.swing.BoxLayout.LINE_AXIS)); 
 
  jLabel1.setText("主机地址:"); 
  jPanel4.add(jLabel1); 
 
  serverTextField.setText("192.168.1.100"); 
  serverTextField.addKeyListener(new java.awt.event.KeyAdapter() { 
   public void keyPressed(java.awt.event.KeyEvent evt) { 
    LinkFTPKeyPressed(evt); 
   } 
  }); 
  jPanel4.add(serverTextField); 
 
  jLabel2.setText("用户名:"); 
  jPanel4.add(jLabel2); 
 
  userTextField.setText("oyp"); 
  userTextField.setMaximumSize(new java.awt.Dimension(200, 2147483647)); 
  userTextField.setPreferredSize(new java.awt.Dimension(100, 21)); 
  userTextField.addKeyListener(new java.awt.event.KeyAdapter() { 
   public void keyPressed(java.awt.event.KeyEvent evt) { 
    LinkFTPKeyPressed(evt); 
   } 
  }); 
  jPanel4.add(userTextField); 
 
  jLabel3.setText("密码:"); 
  jPanel4.add(jLabel3); 
 
  PassField.setText("oyp"); 
  PassField.setMaximumSize(new java.awt.Dimension(200, 2147483647)); 
  PassField.setPreferredSize(new java.awt.Dimension(100, 21)); 
  PassField.addKeyListener(new java.awt.event.KeyAdapter() { 
   public void keyPressed(java.awt.event.KeyEvent evt) { 
    LinkFTPKeyPressed(evt); 
   } 
  }); 
  jPanel4.add(PassField); 
 
  jLabel6.setText("端口:"); 
  jPanel4.add(jLabel6); 
 
  portTextField.setText("21"); 
  portTextField.setMaximumSize(new java.awt.Dimension(100, 2147483647)); 
  portTextField.setPreferredSize(new java.awt.Dimension(50, 21)); 
  portTextField.addKeyListener(new java.awt.event.KeyAdapter() { 
   public void keyPressed(java.awt.event.KeyEvent evt) { 
    LinkFTPKeyPressed(evt); 
   } 
  }); 
  jPanel4.add(portTextField); 
 
  linkButton.setText("连接"); 
  linkButton.setFocusable(false); 
  linkButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); 
  linkButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); 
  linkButton.addActionListener(new java.awt.event.ActionListener() { 
   public void actionPerformed(java.awt.event.ActionEvent evt) { 
    linkButtonActionPerformed(evt); 
   } 
  }); 
  jPanel4.add(linkButton); 
 
  jPanel1.add(jPanel4); 
 
  gridBagConstraints = new java.awt.GridBagConstraints(); 
  gridBagConstraints.gridx = 0; //指定包含组件的显示区域开始边的单元格,其中行的第一个单元格为 gridx=0。 
  gridBagConstraints.gridy = 0; //指定位于组件显示区域的顶部的单元格,其中最上边的单元格为 gridy=0。 
  //当组件的显示区域大于它所请求的显示区域的大小时使用此字段。 
  gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; //在水平方向而不是垂直方向上调整组件大小。 
  gridBagConstraints.weightx = 1.0; //指定如何分布额外的水平空间。 
  getContentPane().add(jPanel1, gridBagConstraints); 
 
  jSplitPane2.setBorder(null); 
  jSplitPane2.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); 
  jSplitPane2.setResizeWeight(1.0); 
  jSplitPane2.setContinuousLayout(true); 
 
  jSplitPane1.setpiderLocation(400); 
  jSplitPane1.setpiderSize(10); 
  jSplitPane1.setOneTouchExpandable(true); 
  jSplitPane1.setRightComponent(ftpPanel); 
  jSplitPane1.setLeftComponent(localPanel); 
 
  jSplitPane2.setLeftComponent(jSplitPane1); 
 
  jTabbedPane1.setMinimumSize(new java.awt.Dimension(40, 170)); 
 
  jTabbedPane1.addTab("队列", queuePanel);// 添加队列面板 
  jTabbedPane1.addTab("上传队列", uploadPanel);// 添加上传面板 
  jTabbedPane1.addTab("下载队列", downloadPanel);// 添加下载面板 
 
  jSplitPane2.setBottomComponent(jTabbedPane1); 
 
  gridBagConstraints = new java.awt.GridBagConstraints(); 
  gridBagConstraints.gridx = 0; 
  gridBagConstraints.gridy = 1; 
  gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; //在水平方向和垂直方向上同时调整组件大小。 
  gridBagConstraints.weightx = 1.0; //指定如何分布额外的水平空间。 
  gridBagConstraints.weighty = 1.0; //指定如何分布额外的垂直空间。 
  getContentPane().add(jSplitPane2, gridBagConstraints); 
 
  fileMenu.setMnemonic('f'); 
  fileMenu.setText("站点(F)"); 
 
  ftpManageMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke( 
    java.awt.event.KeyEvent.VK_S, 
    java.awt.event.InputEvent.CTRL_MASK)); 
  ftpManageMenuItem.setText("FTP站点管理(S)"); 
  ftpManageMenuItem.addActionListener(new ActionListener() { 
   @Override 
   public void actionPerformed(ActionEvent e) { 
//    System.out.println("action"); 
    FtpSiteDialog dialog = new FtpSiteDialog(FTPClientFrame.this); 
    dialog.setVisible(true); 
   } 
  }); 
  fileMenu.add(ftpManageMenuItem); 
  fileMenu.add(jSeparator1); 
 
  linkToMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke( 
    java.awt.event.KeyEvent.VK_C, 
    java.awt.event.InputEvent.CTRL_MASK)); 
  linkToMenuItem.setText("连接到...(C)"); 
  linkToMenuItem.setAction(LINK_TO_ACTION); 
  fileMenu.add(linkToMenuItem); 
 
  cutMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke( 
    java.awt.event.KeyEvent.VK_Z, 
    java.awt.event.InputEvent.CTRL_MASK)); 
  cutMenuItem.setText("断开(Z)"); 
  cutMenuItem.setAction(CUT_LINK_ACTION); 
  fileMenu.add(cutMenuItem); 
  fileMenu.add(jSeparator2); 
 
  exitMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke( 
    java.awt.event.KeyEvent.VK_X, 
    java.awt.event.InputEvent.CTRL_MASK)); 
  exitMenuItem.setText("退出(X)"); 
  exitMenuItem.addActionListener(new ActionListener() { 
   @Override 
   public void actionPerformed(ActionEvent e) { 
    System.exit(0); 
   } 
  }); 
  fileMenu.add(exitMenuItem); 
 
  MenuBar.add(fileMenu); 
 
  JMenu localMenu = new JMenu(); 
  localMenu.setMnemonic('l'); 
  localMenu.setText("本地(L)"); 
 
  uploadMenuItem.setMnemonic('U'); 
  uploadMenuItem.setText("上传(U)"); 
  uploadMenuItem.setAction(localPanel.getActionMap().get("uploadAction")); 
 
  localMenu.add(uploadMenuItem); 
  localMenu.add(jSeparator3); 
 
  createFolderMenuItem.setMnemonic('C'); 
  createFolderMenuItem.setText("新建文件夹(C)"); 
  createFolderMenuItem.setAction(localPanel.getActionMap().get( 
    "createFolderAction")); 
  localMenu.add(createFolderMenuItem); 
 
  renameMenuItem.setMnemonic('R'); 
  renameMenuItem.setText("重命名(R)"); 
  renameMenuItem.setAction(localPanel.getActionMap().get("renameAction")); 
  localMenu.add(renameMenuItem); 
 
  delMenuItem.setMnemonic('D'); 
  delMenuItem.setText("删除(D)"); 
  delMenuItem.setAction(localPanel.getActionMap().get("delAction")); 
  localMenu.add(delMenuItem); 
 
  JMenuItem localrefreshMenuItem = new JMenuItem(); 
  localrefreshMenuItem.setMnemonic('R'); 
  localrefreshMenuItem.setText("刷新(R)"); 
  localrefreshMenuItem.setAction(localPanel.getActionMap().get( 
    "refreshAction")); 
  localMenu.add(localrefreshMenuItem); 
 
  MenuBar.add(localMenu); 
 
  ftpMenu.setMnemonic('r'); 
  ftpMenu.setText("远程(R)"); 
 
  downMenuItem.setMnemonic('U'); 
  downMenuItem.setText("下载(U)"); 
  downMenuItem.setAction(ftpPanel.getActionMap().get("downAction")); 
  ftpMenu.add(downMenuItem); 
  ftpMenu.add(jSeparator6); 
 
  ftpDelMenuItem.setMnemonic('D'); 
  ftpDelMenuItem.setText("删除(D)"); 
  ftpDelMenuItem.setAction(ftpPanel.getActionMap().get("delAction")); 
  ftpMenu.add(ftpDelMenuItem); 
 
  ftpRenameMenuItem.setMnemonic('R'); 
  ftpRenameMenuItem.setText("重命名(R)"); 
  ftpRenameMenuItem 
    .setAction(ftpPanel.getActionMap().get("renameAction")); 
  ftpMenu.add(ftpRenameMenuItem); 
 
  newFolderMenuItem.setMnemonic('C'); 
  newFolderMenuItem.setText("新建文件夹(C)"); 
  newFolderMenuItem.setAction(ftpPanel.getActionMap().get( 
    "createFolderAction")); 
  ftpMenu.add(newFolderMenuItem); 
 
  JMenuItem refreshMenuItem = new JMenuItem(); 
  refreshMenuItem.setMnemonic('R'); 
  refreshMenuItem.setText("刷新(R)"); 
  refreshMenuItem.setAction(ftpPanel.getActionMap().get("refreshAction")); 
  ftpMenu.add(refreshMenuItem); 
 
  MenuBar.add(ftpMenu); 
 
  helpMenu.setText("帮助(H)"); 
  aboutMenuItem.setMnemonic('a'); 
  aboutMenuItem.setText("关于(A)"); 
  aboutMenuItem.addActionListener(new AboutItemAction(this)); 
  helpMenu.add(aboutMenuItem); 
 
  bugMenuItem.setMnemonic('u'); 
  bugMenuItem.setText("错误报告(U)"); 
  bugMenuItem.addActionListener(new BugItemAction()); 
  helpMenu.add(bugMenuItem); 
 
  MenuBar.add(helpMenu); 
 
  setJMenuBar(MenuBar); 
 
  java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit() 
    .getScreenSize(); 
  setBounds((screenSize.width - 800) / 2, (screenSize.height - 600) / 2, 
    800, 700); 
 } 
 
 public JToggleButton getShutdownButton() { 
  return shutdownButton; 
 } 
 
 /** 
  * 窗体装载的事件处理方法 
  */ 
 private void formWindowOpened(java.awt.event.WindowEvent evt) { 
  jSplitPane1.setpiderLocation(0.50); 
  localPanel.getLocalDiskComboBox().setSelectedIndex(1); 
  localPanel.getLocalDiskComboBox().setSelectedIndex(0); 
 } 
 
 /** 
  * 窗体大小调整的事件处理方法 
  */ 
 private void formComponentResized(java.awt.event.ComponentEvent evt) { 
  jSplitPane1.setpiderLocation(0.50); 
 } 
 
 /** 
  * 连接按钮的事件处理方法 
  */ 
 private void linkButtonActionPerformed(java.awt.event.ActionEvent evt) { 
  try { 
   String server = serverTextField.getText(); // 获取服务器地址 
   if (server == null) { 
    return; 
   } 
   String portStr = portTextField.getText(); // 获取端口号 
   if (portStr == null) { 
    portStr = "21"; 
   } 
   int port = Integer.parseInt(portStr.trim()); 
   String userStr = userTextField.getText(); // 获取用户名 
   userStr = userStr == null ? "" : userStr.trim(); 
   String passStr = PassField.getText(); // 获取密码 
   passStr = passStr == null ? "" : passStr.trim(); 
   cutLinkButton.doClick(); 
   ftpClient = new FtpClient(); 
   ftpClient.openServer(server.trim(), port); // 连接服务器 
   ftpClient.login(userStr, passStr); // 登录服务器 
   ftpClient.binary(); // 使用二进制传输模式 
   if (ftpClient.serverIsOpen()) { // 如果连接成功 
    CUT_LINK_ACTION.setEnabled(true); // 设置断开按钮可用 
   } else { // 否则 
    CUT_LINK_ACTION.setEnabled(false); // 设置断开按钮不可用 
    return; // 并结束事件处理 
   } 
   // 设置本地资源管理面板的FTP连接信息 
   localPanel.setFtpClient(server, port, userStr, passStr); 
   // 设置上传按钮可用 
   localPanel.getActionMap().get("uploadAction").setEnabled(true); 
   ftpPanel.setFtpClient(ftpClient);// 设置FTP资源管理面板的FTP连接信息 
   // 设置下载按钮可用 
   ftpPanel.getActionMap().get("downAction").setEnabled(true); 
   ftpPanel.refreshCurrentFolder();// 刷新FTP资源管理面板的当前文件夹 
   queuePanel.startQueue(); // 启动任务队列线程 
  } catch (Exception ex) { 
   ex.printStackTrace(); 
  } 
 } 
 
 /** 
  * 连接FTP相关的文本框 和密码框的回车事件 
  */ 
 private void LinkFTPKeyPressed(java.awt.event.KeyEvent evt) { 
  if (evt.getKeyChar() == '\n') { 
   linkButton.doClick(); 
  } 
 } 
 
 public LocalPanel getLocalPanel() { 
  return localPanel; 
 } 
 
 public FtpPanel getFtpPanel() { 
  return ftpPanel; 
 } 
 
 public QueuePanel getQueuePanel() { 
  return queuePanel; 
 } 
 
 public UploadPanel getUploadPanel() { 
  return uploadPanel; 
 } 
 
 public DownloadPanel getDownloadPanel() { 
  return downloadPanel; 
 } 
 
 public FtpClient getFtpClient() { 
  return ftpClient; 
 } 
 
 /** 
  * 设置FTP连接信息的方法,由FTP站点管理器调用 
  */ 
 public void setLinkInfo(SiteInfoBean bean) { 
  serverTextField.setText(bean.getServer()); // 设置主机地址 
  portTextField.setText(bean.getPort() + ""); // 设置端口号 
  userTextField.setText(bean.getUserName()); // 设置用户名 
  PassField.setText(""); // 密码清空 
  PassField.requestFocus(); // 密码框请求焦点 
 } 
}

整體介面如下:

Java語言實作簡單FTP軟體-FTP軟體主介面的程式碼詳解(四)

以上是Java語言實作簡單FTP軟體-FTP軟體主介面的程式碼詳解(四)的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
如何將Maven或Gradle用於高級Java項目管理,構建自動化和依賴性解決方案?如何將Maven或Gradle用於高級Java項目管理,構建自動化和依賴性解決方案?Mar 17, 2025 pm 05:46 PM

本文討論了使用Maven和Gradle進行Java項目管理,構建自動化和依賴性解決方案,以比較其方法和優化策略。

如何使用適當的版本控制和依賴項管理創建和使用自定義Java庫(JAR文件)?如何使用適當的版本控制和依賴項管理創建和使用自定義Java庫(JAR文件)?Mar 17, 2025 pm 05:45 PM

本文使用Maven和Gradle之類的工具討論了具有適當的版本控制和依賴關係管理的自定義Java庫(JAR文件)的創建和使用。

如何使用咖啡因或Guava Cache等庫在Java應用程序中實現多層緩存?如何使用咖啡因或Guava Cache等庫在Java應用程序中實現多層緩存?Mar 17, 2025 pm 05:44 PM

本文討論了使用咖啡因和Guava緩存在Java中實施多層緩存以提高應用程序性能。它涵蓋設置,集成和績效優勢,以及配置和驅逐政策管理最佳PRA

如何將JPA(Java持久性API)用於具有高級功能(例如緩存和懶惰加載)的對象相關映射?如何將JPA(Java持久性API)用於具有高級功能(例如緩存和懶惰加載)的對象相關映射?Mar 17, 2025 pm 05:43 PM

本文討論了使用JPA進行對象相關映射,並具有高級功能,例如緩存和懶惰加載。它涵蓋了設置,實體映射和優化性能的最佳實踐,同時突出潛在的陷阱。[159個字符]

Java的類負載機制如何起作用,包括不同的類載荷及其委託模型?Java的類負載機制如何起作用,包括不同的類載荷及其委託模型?Mar 17, 2025 pm 05:35 PM

Java的類上載涉及使用帶有引導,擴展程序和應用程序類負載器的分層系統加載,鏈接和初始化類。父代授權模型確保首先加載核心類別,從而影響自定義類LOA

See all articles

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

AI Hentai Generator

AI Hentai Generator

免費產生 AI 無盡。

熱門文章

R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
3 週前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳圖形設置
3 週前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您聽不到任何人,如何修復音頻
3 週前By尊渡假赌尊渡假赌尊渡假赌
WWE 2K25:如何解鎖Myrise中的所有內容
4 週前By尊渡假赌尊渡假赌尊渡假赌

熱工具

SublimeText3 Linux新版

SublimeText3 Linux新版

SublimeText3 Linux最新版

EditPlus 中文破解版

EditPlus 中文破解版

體積小,語法高亮,不支援程式碼提示功能

PhpStorm Mac 版本

PhpStorm Mac 版本

最新(2018.2.1 )專業的PHP整合開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器