appleturlactionhandler.java
来自「Java生成PDF Java生成PDF Java生成PDF」· Java 代码 · 共 63 行
JAVA
63 行
// $Id: AppletURLActionHandler.java,v 1.2 2007/09/12 10:04:59 mike Exp $package org.faceless.pdf2.viewer2.feature;import org.faceless.pdf2.viewer2.*;import org.faceless.pdf2.*;import javax.swing.*;import java.awt.geom.*;import java.awt.*;import java.net.URL;/** * Create an action handler for "URL" actions which will work if this feature is being * run inside an Applet. * The name of this feature is "AppletURLActionHandler". * <p><i>This code is copyright the Big Faceless Organization. You're welcome to use, modify and distribute it in any form in your own projects, provided those projects continue to make use of the Big Faceless PDF library.</i></p> * @since 2.8 */public class AppletURLActionHandler extends ActionHandler{ private static AppletURLActionHandler instance; /** * Return the AppletURLActionHandler */ public static AppletURLActionHandler getInstance() { if (instance==null) instance = new AppletURLActionHandler(); return instance; } private AppletURLActionHandler() { super("AppletURLActionHandler"); } // Next two methods appear slightly over-bulletproofed - the reason is // we're not sure all environments have the applet package. We avoid a // a NoClassDefError in that case public boolean matches(DocumentPanel panel, PDFAction action) { Component c = panel; try { while (c!=null && !(c instanceof java.applet.Applet)) { c = c.getParent(); } } catch (Throwable e) { c = null; } return action.getType().equals("URL") && c!=null; } public void run(DocumentPanel panel, PDFAction action) { Component c = panel; try { while (c!=null && !(c instanceof java.applet.Applet)) { c = c.getParent(); } if (c!=null) { ((java.applet.Applet)c).getAppletContext().showDocument(new URL(action.getURL())); } } catch (Throwable e) {} }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?