[go: up one dir, main page]

Menu

[25f834]: / src / GoTo.java  Maximize  Restore  History

Download this file

40 lines (32 with data), 869 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import java.awt.Cursor;
import java.awt.Desktop;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import javax.swing.JLabel;
public class GoTo {
JLabel label;
String link;
public GoTo(JLabel label, String link) {
super();
this.label = label;
this.link = link;
}
public GoTo() {
// TODO Auto-generated constructor stub
}
public void Go(JLabel label,String link){
label.setCursor(new Cursor(Cursor.HAND_CURSOR));
label.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
try {
Desktop.getDesktop().browse(new URI(link));
} catch (URISyntaxException | IOException ex) {
}
}
});
}
}