?? jhtmlviewer.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 + -