View Javadoc

1   package org.abstracthorizon.aequo.gui;
2   
3   import java.awt.Component;
4   import java.awt.Cursor;
5   import java.awt.event.MouseEvent;
6   import java.awt.event.MouseListener;
7   
8   import org.abstracthorizon.aequo.util.BrowserUtility;
9   
10  /**
11   * This class changes the cursor to hand cursor when over the specified component. If mouse is clicked
12   * then browser is invoked.
13   * 
14   * @author Daniel Sendula
15   */
16  public class URLLink implements MouseListener {
17      
18      /** URL to be invoked */
19      protected String url;
20      
21      /** Component cursor to be set on */
22      protected Component component;
23      
24      /**
25       * Constructor 
26       * @param url url to be invoked
27       * @param component component cursor to be set on
28       */
29      public URLLink(String url, Component component) {
30          this.url = url;
31          this.component = component;
32      }
33  
34      public void mouseClicked(MouseEvent e) {
35          BrowserUtility.openURL(url);
36      }
37  
38      public void mouseEntered(MouseEvent e) {
39          component.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
40      }
41  
42      public void mouseExited(MouseEvent e) {
43          component.setCursor(Cursor.getDefaultCursor());
44      }
45  
46      public void mousePressed(MouseEvent e) { }
47  
48      public void mouseReleased(MouseEvent e) { }
49      
50  }