+package jp.naist.se.stigmata.ui.swing.actions;\r
+\r
+/*\r
+ * $Id$\r
+ */\r
+\r
+import java.io.IOException;\r
+import java.lang.reflect.Method;\r
+import java.net.URL;\r
+\r
+import javax.swing.JEditorPane;\r
+import javax.swing.event.HyperlinkListener;\r
+import javax.swing.event.HyperlinkEvent;\r
+\r
+/**\r
+ *\r
+ * @author Haruaki Tamada\r
+ * @version $Revision$ $Date$\r
+ */\r
+class LinkFollower implements HyperlinkListener{\r
+ public void hyperlinkUpdate(HyperlinkEvent e){\r
+ JEditorPane text = (JEditorPane)e.getSource();\r
+ if(e.getEventType() == HyperlinkEvent.EventType.ACTIVATED){\r
+ URL url = null;\r
+ try{\r
+ url = e.getURL();\r
+ browse(url);\r
+ } catch(RuntimeException ee){\r
+ throw ee;\r
+ } catch(Exception ee){\r
+ ee.printStackTrace();\r
+ }\r
+ }\r
+ }\r
+\r
+ private void browse(URL url) throws Exception{\r
+ Class c = Class.forName("edu.stanford.ejalbert.BrowserLauncher");\r
+ Object o = c.newInstance();\r
+ Method m = c.getMethod("openURLinBrowser", String.class);\r
+ m.invoke(o, url.toString());\r
+ }\r
+}
\ No newline at end of file