This is not a direct answer to your question. If I correctly understood the slowness, you are faced with some strange flashes and visualization. To reduce slowness, the size of the webView can be updated manually and more rarely:
import javafx.animation.KeyFrame; import javafx.animation.Timeline; import javafx.application.Application; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.Scene; import javafx.scene.layout.Pane; import javafx.scene.layout.PaneBuilder; import javafx.scene.web.WebView; import javafx.stage.Stage; import javafx.util.Duration; public class KSO_Demo extends Application { @Override public void start(Stage primaryStage) { final WebView webView = new WebView(); webView.getEngine().loadContent("<div style='background-color: gray; height: 100%'>Some content</div>"); final Pane pane = PaneBuilder.create().children(webView).style("-fx-border-color: blue").build(); final Timeline animation = new Timeline( new KeyFrame(Duration.seconds(.5), new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { webView.setPrefSize(pane.getWidth(), pane.getHeight()); } })); animation.setCycleCount(1); primaryStage.setScene(new Scene(pane, 300, 250)); primaryStage.widthProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> arg0, Number arg1, Number arg2) { animation.play(); } }); primaryStage.heightProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> arg0, Number arg1, Number arg2) { animation.play(); } }); primaryStage.show(); } public static void main(String[] args) { launch(args); } }
WebView is in Pane , which does not automatically break its children. Web browser size updates are delayed by 0.5 seconds, ignoring updates in the interval.
Uluk Biy
source share