In my JavaFX program, I have a Label that is coded to open a new stage on click. The new stage opens up just fine when I execute the program in IDE but the it just won't show up when I launch the program in JAR Format.

Here's the code for the Label

    l2.setOnMouseClicked(e -> {
        signUp sign = new signUp();
        stackPane.setEffect(new BoxBlur(3, 3, 3));
        sign.signups().showAndWait();
        stackPane.setEffect(new BoxBlur(0, 0, 0));

    });

Here's the code for the function that returns the stage when the Label is clicked.

     public Class signUp{
    Scene scene;
     public Stage signups() {
    Stage stage = new Stage();

    stackPane = new StackPane();
    GridPane gridPane = new GridPane();
    gridPane.setStyle("-fx-background-color:white;" + "-fx-effect:dropshadow(three-pass-box, rgba(0,0,0,0.8), 10, 0, 0, 0);" + "-fx-background-radius:10;");
    gridPane.setMaxSize(280, 350);
    gridPane.setPadding(new Insets(10));


    gridPane.setHgap(10);
    gridPane.setVgap(10);
    stackPane1 = new StackPane();
    BackgroundImage bg = new BackgroundImage(new Image("bread.jpg", 960, 540, false, true),
            BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER,
            BackgroundSize.DEFAULT);
    stackPane1.setBackground(new Background(bg));

    double x = 20;

    username = new JFXTextField();
    username.setPromptText("Username");
    password = new JFXPasswordField();
    password.setPromptText("Password");
    password1 = new JFXPasswordField();
    password1.setPromptText("Re-type Password");
    username.setMinWidth(220);
    password.setMinWidth(220);
    password1.setMinWidth(220);


    JFXButton sign_up = new JFXButton("Sign Up");
    sign_up.setTextFill(Color.WHITE);
    sign_up.setStyle("-fx-background-color:#2196F3");
    sign_up.setMinSize(220, 30);
    sign_up.setOnMouseEntered(e->{
        scene.setCursor(Cursor.HAND);
    });
    sign_up.setOnMouseExited(e->{
        scene.setCursor(Cursor.DEFAULT);
    });


    agreement = new JFXCheckBox("I accept the Terms & Conditions");

    ImageView logo = new ImageView(new Image("logo.png"));
    logo.setFitWidth(200);
    logo.setFitHeight(130);

    gridPane.add(logo, 1, 0);

    gridPane.add(username, 0, 1, 3, 1);
    gridPane.add(password, 0, 2, 3, 1);
    gridPane.add(password1, 0, 3, 3, 1);
    gridPane.add(agreement, 0, 4, 3, 1);
    gridPane.add(sign_up, 0, 5, 3, 1);
    gridPane.setAlignment(Pos.CENTER);
    gridPane.setHalignment(sign_up, HPos.LEFT);
    gridPane.setHalignment(username, HPos.CENTER);
    gridPane.setHalignment(password, HPos.CENTER);
    gridPane.setHalignment(password1, HPos.CENTER);
    gridPane.setHalignment(logo, HPos.CENTER);
    gridPane.setValignment(sign_up, VPos.BOTTOM);


    stackPane.setAlignment(Pos.CENTER);


    stackPane1.getChildren().add(gridPane);
    stackPane.getChildren().add(stackPane1);
    scene = new Scene(stackPane, 380, 400);
    stage.setScene(scene);
    stage.setTitle("Sign Up");
    stage.initModality(Modality.APPLICATION_MODAL);


    return stage;


}
    }

0 Answers