miniHessel
miniHessel

Reputation: 846

Transparent Divider in SplitPane

Is there any way to make the Divider in a split pane transparent?

I have tried the following approach

.split-pane *.split-pane-divider {
-fx-padding: 0 1 0 1;
}

But it doesn't work.

Also, I would rather do it from the java code, if it's possible.

splitPane.setStyle(""); 

Upvotes: 6

Views: 11183

Answers (2)

James_D
James_D

Reputation: 209684

Depending on what you're actually trying to do,

.split-pane-divider {
  -fx-padding: 0 ;
}

might work.

Why would you want to make the divider transparent? It makes it virtually impossible for the user to resize the portions of the pane.

Upvotes: 5

José Pereda
José Pereda

Reputation: 45486

With CSS:

.split-pane:horizontal > .split-pane-divider {
   -fx-background-color: transparent;
}
.split-pane:vertical > .split-pane-divider {
   -fx-background-color: transparent;
}

By code, you need to find the divider and apply the style to it. Since there's no API for that, one easy way is with a lookup, after the stage is shown:

@Override
public void start(Stage primaryStage) {    
    SplitPane split = new SplitPane();
    ...
    Scene scene = new Scene(split);
    primaryStage.setScene(scene);
    primaryStage.show();

    Node divider = split.lookup(".split-pane-divider");
    if(divider!=null){
        divider.setStyle("-fx-background-color: transparent;");
    }
}

Upvotes: 11

Related Questions