source: josm/src/org/openstreetmap/josm/tools/UrlLabel.java@ 196

Last change on this file since 196 was 159, checked in by imi, 18 years ago
  • moved translations into plugins
  • added main menu control to main
  • added ImageProvider access to plugins
File size: 831 bytes
Line 
1package org.openstreetmap.josm.tools;
2
3import javax.swing.JEditorPane;
4import javax.swing.event.HyperlinkEvent;
5import javax.swing.event.HyperlinkListener;
6
7/**
8 * Label that contains a clickable link.
9 * @author Imi
10 */
11public class UrlLabel extends JEditorPane implements HyperlinkListener {
12
13 private final String url;
14
15 public UrlLabel(String url) {
16 this (url, url);
17 }
18
19 public UrlLabel(String url, String description) {
20 this.url = url;
21 setContentType("text/html");
22 setText("<html><a href=\""+url+"\">"+description+"</a></html>");
23 setToolTipText(url);
24 setEditable(false);
25 setOpaque(false);
26 addHyperlinkListener(this);
27 }
28
29 public void hyperlinkUpdate(HyperlinkEvent e) {
30 if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
31 OpenBrowser.displayUrl(url);
32 }
33 }
34}
Note: See TracBrowser for help on using the repository browser.