0

I woudlike to restart my application JavaFX after click on button restart :

public boolean restartPopup(String text) {

    Alert majConfirmation = new Alert(Alert.AlertType.CONFIRMATION);

    majConfirmation.setHeaderText(text);

    Button confirmMAJ = (Button) majConfirmation.getDialogPane().lookupButton(ButtonType.OK);
    confirmMAJ.setText("Restart");
    Button cancelMAJ = (Button) majConfirmation.getDialogPane().lookupButton(ButtonType.CANCEL);
    cancelMAJ.setText("Non");
    majConfirmation.initModality(Modality.APPLICATION_MODAL);
    majConfirmation.initOwner(primaryStage);

    Optional < ButtonType > majResponse = majConfirmation.showAndWait();
    if (ButtonType.OK.equals(majResponse.get())) {
        logger.info("MAJ application");
        return true;
    } else {
        return false;
    }
}

I was looking at System.out() function but I found nothing about restart app.

M. Dudek
  • 978
  • 7
  • 28
Software14
  • 155
  • 1
  • 9
  • may be duplicate of https://stackoverflow.com/questions/34788026/how-to-restart-a-javafx-application-when-a-button-is-clicked – eHayik May 20 '21 at 06:54
  • "_I was looking at `System.out()` function_" – Where are you seeing this function? There's a `System.exit()` method, which obviously just exits the JVM. There's also a `System.out` **field** which let's you print to the standard output stream. – Slaw May 20 '21 at 09:35
  • 2
    Anyway, there is no API in JavaFX or standard Java that allows you to restart the entire process. You can try to "restart" your application by resetting the state (as shown in the linked question above). – Slaw May 20 '21 at 09:38
  • Why you should restart a Java appl.? You can just refresh/reload what you need. – Raw May 21 '21 at 09:19

0 Answers0