Leave a field of Bordepane transparent Javafx

Asked

Viewed 51 times

0

Good morning, I’m trying to make only one of the components of a Borderpane look transparent. In this case I used . opacity, however it was in Stage.

Code I created:

@Override
public void start(Stage primaryStage) throws Exception {
    BorderPane root = FXMLLoader.load(getClass().getResource("App.fxml"));
    Scene scene = new Scene(root);
    primaryStage.setScene(scene);
    primaryStage.setOpacity(0.5);
    primaryStage.show();
}

And this is the sample image:inserir a descrição da imagem aqui

I want only the part in blue to be Transparent and not the whole program, I have tried an opacity within the FXML in the part where I want to leave Transparent, but it was not the result obtained, because it just leaves the part in a clearer aspect.

  • This might help: https://stackoverflow.com/questions/22663681/javafx-effect-on-background

  • Dear thanks for the reply, it was the same that I found when watching a video on youtube of javafx inspirations.

1 answer

1

I found out how.

just putting:

        scene.setFill(Color.TRANSPARENT);
    stage.initStyle(StageStyle.TRANSPARENT);

with this your app will be transparent, but when editing the . fxml and by others Node and by a color and by opacity in that Node it will have the desired effect.

Upshot:

inserir a descrição da imagem aqui

Browser other questions tagged

You are not signed in. Login or sign up in order to post.