-
Notifications
You must be signed in to change notification settings - Fork 0
/
HyperlinkSegment.java
35 lines (28 loc) · 1.07 KB
/
HyperlinkSegment.java
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
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Node;
import javafx.scene.control.Hyperlink;
public class HyperlinkSegment extends AbstractSegment {
private final String caption;
private final String url;
private Hyperlink hyperlink;
public HyperlinkSegment(String caption, String url) {
this.caption = caption;
this.url = url;
hyperlink = null;
}
@Override
public Node createNode( String style ) {
hyperlink = new Hyperlink(caption);
hyperlink.getStyleClass().add("text");
hyperlink.setStyle(style); //.toCss());
hyperlink.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent e) {
System.out.printf("hyperlink was clicked - url: '%s', hyperlink: %s, visited: %s\n", url, hyperlink, hyperlink.isVisited());
}
});
System.out.printf("createNode/HyperLinkSegment: caption: '%s'\n", caption);
return hyperlink;
}
}