I tried implementing some existing solutions, which could not help me. A string is received from API "You can visit out website:http://localhost:0000/stack_overflow/". This whole string needs to be displayed. I want to split the String in such a way to make the "http://localhost:0000/stack_overflow/" part a hyperlink and clickable.
I tried using TextFlow and splitting the text into Text and Hyperlink, however, when I split using the ":", all the ":" come into play breaking the String.
String urlLink = "You can visit out website:http://localhost:0000/stack_overflow/";
TextFlow textFlow = new TextFlow();
ImageView imageView = new ImageView();
imageView.setImage(new Image(Resources.ICON));
String[] information = urlLink.split(":");
Text txtInfo = new Text(information[0]);
Hyperlink link = new Hyperlink(information[1]);
link.setOnAction(event -> {
try {
Runtime.getRuntime().exec("cmd.exe /c start iexplore " + link);
} catch (IOException e) {
e.printStackTrace();
}
});
textFlow = new TextFlow(txtInfo, link);