1

Trying to create a drop-shadow to my BorderPane. I need to use a StackPane to allow room for the drop-shadow. The problem is I cannot seem to set the background of StackPane to transparent. I am using transparent style for my primiaryStage.

There are other example using javaFX which work but, I can't figure it out when using fxml.

.StackPane{
  -fx-background-color: transparent;
}

This still shows a white background behind my BorderPane

public class Main extends Application {


    public static Stage Window;

    @Override
    public void start(Stage primaryStage) throws IOException{
        Main.Window = primaryStage;
        Window.initStyle(StageStyle.TRANSPARENT);
        Window.setResizable(false);
        FXMLLoader loader = new FXMLLoader(getClass().getResource("Homepage.fxml"));
        Parent root = loader.load();    
        Window.setScene(new Scene(root));
        root.getStylesheets().add(getClass().getResource("main.css").toExternalForm());

        Window.show();
    }

enter image description here

  • 1
    Perhaps a duplicate of: [How do I create a JavaFX transparent stage with shadows on only the border?](http://stackoverflow.com/questions/25534204/how-do-i-create-a-javafx-transparent-stage-with-shadows-on-only-the-border) – jewelsea Dec 07 '16 at 19:50

2 Answers2

1

I found that when using a scroll pane it would dynamically create stack panes under it during runtime. Using scenic view I was able to see the style class name as 'viewport' and could change the background color that way.

AronAtVW
  • 115
  • 1
  • 2
  • 11
0

Setting the window style might not work because the OS you are working on doesnt suppot that style. The documentation says about this:

On some platforms decorations might not be available.

But for a workaround for the stackpane, you should provide an example image of what you are aiming for. Right now its rather unclear what exactually you are trying to accomplish.

n247s
  • 1,898
  • 1
  • 12
  • 30