Last change
on this file since 1724 was 1169, checked in by stoecker, 15 years ago |
removed usage of tab stops
|
-
Property svn:eol-style
set to
native
|
File size:
949 bytes
|
Line | |
---|
1 | // License: GPL. Copyright 2007 by Immanuel Scholz and others
|
---|
2 | package org.openstreetmap.josm.tools;
|
---|
3 |
|
---|
4 | import javax.swing.JEditorPane;
|
---|
5 | import javax.swing.event.HyperlinkEvent;
|
---|
6 | import javax.swing.event.HyperlinkListener;
|
---|
7 |
|
---|
8 | /**
|
---|
9 | * Label that contains a clickable link.
|
---|
10 | * @author Imi
|
---|
11 | */
|
---|
12 | public class UrlLabel extends JEditorPane implements HyperlinkListener {
|
---|
13 |
|
---|
14 | private final String url;
|
---|
15 |
|
---|
16 | public UrlLabel(String url) {
|
---|
17 | this (url, url);
|
---|
18 | }
|
---|
19 |
|
---|
20 | public UrlLabel(String url, String description) {
|
---|
21 | this.url = url;
|
---|
22 | setContentType("text/html");
|
---|
23 | setText("<html><a href=\""+url+"\">"+description+"</a></html>");
|
---|
24 | setToolTipText(url);
|
---|
25 | setEditable(false);
|
---|
26 | setOpaque(false);
|
---|
27 | addHyperlinkListener(this);
|
---|
28 | }
|
---|
29 |
|
---|
30 | public void hyperlinkUpdate(HyperlinkEvent e) {
|
---|
31 | if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
|
---|
32 | OpenBrowser.displayUrl(url);
|
---|
33 | }
|
---|
34 | }
|
---|
35 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.