⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ftpaboutpanel.java

📁 一个利用Java语言实现的ftp程序
💻 JAVA
字号:
/*
 * Copyright (C) The Apache Software Foundation. All rights reserved.
 *
 * This software is published under the terms of the Apache Software License
 * version 1.1, a copy of which has been included with this distribution in
 * the LICENSE file.
 */
package server.ftp.gui;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.io.InputStream;

import javax.swing.JButton;
import javax.swing.JEditorPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.HTMLFrameHyperlinkEvent;

import gui.GuiUtils;
import io.IoUtils;
import server.ftp.FtpConfig;

/**
 * Displays <a href="about.html">about.html</a> page.
 *
 * @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
 */
public
class FtpAboutPanel extends PluginPanel implements HyperlinkListener {
    
    public final static String ABOUT_PAGE = "server/ftp/gui/about.html";
    
    private String mstHomeContent; 
    private JEditorPane mjEditorPane = null;    
  
    /**
     * Constructor.
     */
    public FtpAboutPanel(FtpTree tree) {
        super(tree);
        initComponents();
    }
    
    
    /**
     * Initialize GUI components.
     */
    private void initComponents() {
        setLayout(new BorderLayout());
        mjEditorPane = new JEditorPane();
        mjEditorPane.setEditable(false);
        mjEditorPane.setContentType("text/html");
        goHome();
        mjEditorPane.addHyperlinkListener(this);
        
        JScrollPane editorScrollPane = new JScrollPane(mjEditorPane);
        editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        editorScrollPane.setPreferredSize(new Dimension(480, 340));
        add(editorScrollPane, BorderLayout.CENTER);
       
        JPanel bottomPane = new JPanel();
        bottomPane.setLayout(new FlowLayout(FlowLayout.CENTER));
        JButton homeButton = new JButton("Home");
        homeButton.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent evt) {
                goHome();
             }
        });
        bottomPane.add(homeButton);
        add(bottomPane, BorderLayout.SOUTH);
    }
    
    /**
     * Handle user mouse click.
     */
    public void hyperlinkUpdate(HyperlinkEvent e) {
        try {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                JEditorPane pane = (JEditorPane) e.getSource();
                if (e instanceof HTMLFrameHyperlinkEvent) {
                    HTMLFrameHyperlinkEvent  evt = (HTMLFrameHyperlinkEvent)e;
                    HTMLDocument doc = (HTMLDocument)pane.getDocument();
                    doc.processHTMLFrameHyperlinkEvent(evt);
                } 
                else {
                    pane.setPage(e.getURL());
                }
            }
        }
        catch(Throwable th) {
        }
    }
    
    /**
     * Display about page
     */
    private void goHome() {
        InputStream is = null;
        try {
            mjEditorPane.setContentType("text/html");
            is = getClass().getClassLoader().getResourceAsStream(ABOUT_PAGE);
            if (is != null) {
                mjEditorPane.read(is, null);
            }
        }
        catch(IOException ex) {
            GuiUtils.showErrorMessage(getTree().getRootPanel(), ex.getMessage());
        }
        finally {
            IoUtils.close(is);
        }
    }   

    /**
     * Reload new configuration - does nothing
     */ 
    public void refresh(FtpConfig config) {
    }
    
    /**
     * Is displayable in the root pane.
     */
    public boolean isDisplayable() {
        return true;
    } 
    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -