I want to do an auto refresh of JavaFX WebView. Can you help me with that? Estimated needs to be refreshed every 10 seconds
package ui;
import java.io.IOException;
import host.*;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
public class MainUİ extends Application {
@Override
public void start(Stage primaryStage) throws IOException {
StackPane root = new StackPane();
WebView webView = new WebView();
WebEngine webEngine = webView.getEngine();
//get read .txt file and connect hostinfo
GetHost host = new GetHost();
String hostinfo = host.getHost();
webEngine.load(hostinfo);
root.getChildren().add(webView);
Scene scene = new Scene(root);
primaryStage.setTitle("Evren-Software");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
I'm going to make a mirror on the big screen, so I need to refresh. I used it with .reload but it didn't work. every 10 seconds
reload()method on yourWebEngineon a loop that pauses 10 seconds between each iteration?webEngine.executeScript("myFunction()");where myFunction can be used to refresh the page on javascript side. Check this link