Open Swetha-gs7792 opened 1 week ago
package WebViewExample; import javafx.application.Application; import javafx.concurrent.Worker; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.layout.StackPane; import javafx.scene.web.WebEngine; import javafx.scene.web.WebView; import javafx.stage.Stage;
import java.util.Timer; import java.util.TimerTask;
public class WebViewExample extends Application {
private WebView webView;
private WebEngine webEngine;
private Button retryButton;
private Timer retryTimer;
@Override
public void start(Stage primaryStage) {
webView = new WebView();
webEngine = webView.getEngine();
// Set up WebView and retry button
setUpWebView();
setUpRetryButton();
// Create layout
StackPane root = new StackPane();
root.getChildren().addAll(webView, retryButton);
// Create scene
Scene scene = new Scene(root, 800, 600);
// Set up stage
primaryStage.setTitle("JavaFX WebView title");
primaryStage.setScene(scene);
primaryStage.show();
// Load initial URL
loadURL("https://www.google.com/");
}
private void setUpWebView() {
webEngine.getLoadWorker().stateProperty().addListener((observable, oldState, newState) -> {
if (newState == Worker.State.SUCCEEDED) {
System.out.println("Page loaded successfully.");
// Additional handling after successful load if needed
} else if (newState == Worker.State.FAILED) {
System.out.println("Page failed to load.");
handleLoadFailure();
}
});
}
private void setUpRetryButton() {
retryButton = new Button("Retry");
retryButton.setOnAction(event -> {
retryButton.setDisable(true); // Disable retry button during retry attempt
loadURL("https://www.google.com/");
});
retryButton.setVisible(false); // Initially hide retry button
}
private void loadURL(String url) {
try {
webEngine.load(url);
} catch (Exception e) {
System.err.println("Error loading URL: " + e.getMessage());
e.printStackTrace();
handleLoadFailure();
}
}
private void handleLoadFailure() {
// Show retry button
retryButton.setVisible(true);
// Schedule retry after 5 seconds
retryTimer = new Timer();
retryTimer.schedule(new TimerTask() {
@Override
public void run() {
retryButton.setDisable(false); // Enable retry button
retryTimer.cancel(); // Cancel the timer after one execution
}
}, 5000); // 5000 milliseconds = 5 seconds
}
public static void main(String[] args) {
launch(args);
}
}
Sir @Johan Vos ,@Eugene Ryzhikov @Joeri Sykora please help
Originally posted by @kevinrushforth in https://github.com/javafxports/openjdk-jfx/issues/237#issuecomment-427207895 I am using javafx17 32 bit gluon and azul jdk17 32 bit and i am unable to launch the clound link authentication screen . landing into same no toolkit found faces redirect issue