KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > admin > common > XEditorPane


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.admin.common;
5
6 import org.dijon.EditorPane;
7
8 import javax.swing.event.HyperlinkEvent JavaDoc;
9 import javax.swing.event.HyperlinkListener JavaDoc;
10 import javax.swing.text.html.HTMLDocument JavaDoc;
11 import javax.swing.text.html.HTMLFrameHyperlinkEvent JavaDoc;
12
13 public class XEditorPane extends EditorPane {
14   public XEditorPane() {
15     super();
16     addHyperlinkListener(new Hyperactive());
17   }
18
19   class Hyperactive implements HyperlinkListener JavaDoc {
20     public void hyperlinkUpdate(HyperlinkEvent JavaDoc 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 JavaDoc) {
27           HTMLFrameHyperlinkEvent JavaDoc evt = (HTMLFrameHyperlinkEvent JavaDoc)e;
28           HTMLDocument JavaDoc doc = (HTMLDocument JavaDoc)pane.getDocument();
29
30           doc.processHTMLFrameHyperlinkEvent(evt);
31         }
32         else {
33           try {
34                   pane.setPage(e.getURL());
35           }
36           catch(Throwable JavaDoc t) {
37                   t.printStackTrace();
38           }
39         }
40       }
41     }
42   }
43 }
44
Popular Tags