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

📄 jhtmlviewer.java

📁 JavaExplorer是一个独立于平台的浏览器
💻 JAVA
字号:
/**  * XFile and FTP Explorer  * Copyright 2002  * BOESCH Vincent  *  * This program is free software; you can redistribute it and/or  * modify it under the terms of the GNU General Public License  * as published by the Free Software Foundation; either version 2  * of the License, or (at your option) any later version.  *  * This program is distributed in the hope that it will be useful,  * but WITHOUT ANY WARRANTY; without even the implied warranty of  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  * GNU General Public License for more details.  *  * You should have received a copy of the GNU General Public License  * along with this program; if not, write to the Free Software  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.  */package javaexplorer.gui.viewer;import java.awt.*;import java.io.*;import javaexplorer.Launcher;import javaexplorer.gui.listener.ViewerListener;import javaexplorer.model.XFile;import javaexplorer.util.ExplorerUtil;import javax.swing.*;public class JHTMLViewer extends JScrollPane implements Viewer {    private XFile _xfile = null;    private JEditorPane _jep = new JEditorPane();    private Font _defaultFont = _jep.getFont();    private Launcher _launcher = null;    /**     *  Constructor for the JHTMLViewer object     */    public JHTMLViewer() {        super();        _jep.setEditorKit(new javax.swing.text.html.HTMLEditorKit());        JPanel p = new JPanel();        p.setLayout(new BorderLayout());        p.add(_jep, BorderLayout.CENTER);        getViewport().add(p);    }    /**     *  Adds a feature to the ViewerListener     *  attribute of the JHTMLViewer object     *     *@param  vl  The feature to be added to     *      the ViewerListener attribute     */    public void addViewerListener(ViewerListener vl) {        _jep.addMouseListener(vl);    }    /**     *  Description of the Method     *     *@param  e_zoomFactor  Description of     *      Parameter     */    public void applyZoom(int e_zoomFactor) {        Font f = _jep.getFont();        switch (e_zoomFactor) {        case ExplorerUtil.ZOOM_IN:            f = new Font(f.getName(), f.getStyle(), f.getSize() + 1);            break;        case ExplorerUtil.ZOOM_OUT:            f = new Font(f.getName(), f.getStyle(), Math.max(f.getSize() - 1, 2));            break;        default:        case ExplorerUtil.ZOOM_FIT:        case ExplorerUtil.ZOOM_NO:            f = _defaultFont;            break;        }        _jep.setFont(f);    }    /**     */    public void freeRessource() {    }    /**     *  Gets the XFile attribute of the JHTMLViewer     *  object     *     *@return    The XFile value     */    public XFile getXFile() {        return _xfile;    }    /**     *  Gets the Info attribute of the JHTMLViewer     *  object     *     *@return    The Info value     */    public String getInfo() {        return _xfile.getName();    }    /**     *  Gets the JComponent attribute of the     *  JHTMLViewer object     *     *@return    The JComponent value     */    public JComponent getJComponent() {        return this;    }    /**     *  Gets the MinimumSize attribute of the     *  JHTMLViewer object     *     *@return    The MinimumSize value     */    public Dimension getMinimumSize() {        return new Dimension(25, 25);    }    /**     *  Gets the PreferredSize attribute of     *  the JHTMLViewer object     *     *@return    The PreferredSize value     */    public Dimension getPreferredSize() {        return new Dimension(100, 100);    }    /**     *  Sets the XFile attribute of the JHTMLViewer     *  object     *     *@param  e_file  The new XFile value     */    public void setXFile(XFile e_file) {        _xfile = e_file;        try {            InputStream is = _xfile.getInputStream(0);            int avail = is.available();            byte[] buf = new byte[avail];            is.read(buf);            is.close();            _jep.setText(new String(buf));            System.gc();        } catch (Exception e) {            javaexplorer.util.Log.addError(e);        }        repaint();    }    /**     *  Sets the launcher attribute of the     *  JHTMLViewer object     *     *@param  launcher  The new launcher value     */    public void setLauncher(Launcher launcher) {        _launcher = launcher;    }}

⌨️ 快捷键说明

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