1 4 package com.tc.admin.common; 5 6 import org.dijon.EditorPane; 7 8 import javax.swing.event.HyperlinkEvent ; 9 import javax.swing.event.HyperlinkListener ; 10 import javax.swing.text.html.HTMLDocument ; 11 import javax.swing.text.html.HTMLFrameHyperlinkEvent ; 12 13 public class XEditorPane extends EditorPane { 14 public XEditorPane() { 15 super(); 16 addHyperlinkListener(new Hyperactive()); 17 } 18 19 class Hyperactive implements HyperlinkListener { 20 public void hyperlinkUpdate(HyperlinkEvent e) { 21 System.out.println(e); 22 23 if(e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { 24 XEditorPane pane = (XEditorPane)e.getSource(); 25 26 if(e instanceof HTMLFrameHyperlinkEvent ) { 27 HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent )e; 28 HTMLDocument doc = (HTMLDocument )pane.getDocument(); 29 30 doc.processHTMLFrameHyperlinkEvent(evt); 31 } 32 else { 33 try { 34 pane.setPage(e.getURL()); 35 } 36 catch(Throwable t) { 37 t.printStackTrace(); 38 } 39 } 40 } 41 } 42 } 43 } 44 | Popular Tags |