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

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

HTMLEditor htmlEditor = new HTMLEditor();
htmlEditor.setPrefSize(600, 500);
//獲取內容
String htmlText = htmlEditor.getHtmlText();
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章