JavaFX 控件 Hyperlink WebView HTMLEditor

Hyperlink WebView HTMLEditor

Hyperlink

Hyperlink hyperlink = new Hyperlink("www.baidu.com");
hyperlink.setOnAction(new EventHandler<ActionEvent>() {
    @Override
    public void handle(ActionEvent event) {
        HostServices hostServices = getHostServices();
        hostServices.showDocument(hyperlink.getText());
    }
});

WebView

JavaFX 控件 Hyperlink WebView HTMLEditor_第1张图片

WebView webView = new WebView();
WebEngine engine = webView.getEngine();
engine.load("http://www.baidu.com");
webView.prefWidthProperty().bind(root.widthProperty());
webView.prefHeightProperty().bind(root.heightProperty());
//页面历史
WebHistory history = engine.getHistory();
ObservableList<Entry> historyEntries = history.getEntries();
//前进
history.go(1);
//后退
history.go(-1);

HTMLEditor

JavaFX 控件 Hyperlink WebView HTMLEditor_第2张图片

HTMLEditor htmlEditor = new HTMLEditor();
htmlEditor.setPrefSize(600, 500);
//获取内容
String htmlText = htmlEditor.getHtmlText();

你可能感兴趣的:(JavaFX,Java,JavaFX)