OSDN Git Service

pom.xml の macosxbundle maven2 pluginがうまく動かないので,コメントアウトした.
[stigmata/stigmata.git] / src / main / java / jp / sourceforge / stigmata / ui / swing / actions / LinkFollower.java
1 package jp.sourceforge.stigmata.ui.swing.actions;
2
3 /*
4  * $Id$
5  */
6
7 import java.awt.Desktop;
8 import java.net.URL;
9
10 import javax.swing.event.HyperlinkEvent;
11 import javax.swing.event.HyperlinkListener;
12
13 /**
14  *
15  * @author Haruaki Tamada
16  * @version $Revision$ 
17  */
18 class LinkFollower implements HyperlinkListener{
19     public void hyperlinkUpdate(HyperlinkEvent e){
20         if(e.getEventType() == HyperlinkEvent.EventType.ACTIVATED){
21             URL url = null;
22             try{
23                 url = e.getURL();
24                 browse(url);
25             } catch(RuntimeException ee){
26                 throw ee;
27             } catch(Exception ee){
28                 ee.printStackTrace();
29             }
30         }
31     }
32
33     private void browse(URL url) throws Exception{
34         Desktop desktop = Desktop.getDesktop();
35         if(desktop.isSupported(Desktop.Action.BROWSE)){
36                 desktop.browse(url.toURI());
37         }
38     }
39 }