Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transparent Divider in SplitPane

Tags:

javafx

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(""); 
like image 724
miniHessel Avatar asked Dec 05 '14 14:12

miniHessel


1 Answers

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;");
    }
}
like image 118
José Pereda Avatar answered Sep 30 '22 23:09

José Pereda