The embedded WebView browser I am using needs special handling for particular URLs, to open them in the native default browser instead of WebView. The actual browsing part w
2017 version - still very hacky but much more concise:
class AboutDialog extends Dialog {
private final Controller controller;
private final String url;
AboutDialog() {
super();
this.controller = Controller.getInstance();
this.setTitle(controller.getProperty("about_title"));
this.setHeaderText(null);
this.url = getClass().getResource("/about_dialog.html").toExternalForm();
this.setWebView();
this.getDialogPane().getButtonTypes().add(new ButtonType(controller.getProperty("close"), ButtonBar.ButtonData.CANCEL_CLOSE));
this.getDialogPane().setPrefWidth(600);
}
private void setWebView() {
final WebView webView = new WebView();
webView.getEngine().load(url);
webView.getEngine().locationProperty().addListener((observable, oldValue, newValue) -> {
controller.getMainFxApp().getHostServices().showDocument(newValue);
Platform.runLater(this::setWebView);
});
this.getDialogPane().setContent(webView);
}
}