0

Is there a way to set margin between TitledPane in javafx?

I created multiple titledpanes and put them altogether inside a VBox. I want it to have a gap between each titledpane.

I looked up setMargin() method to achieve it, but it doesn't seem to be exist.

I also tried with css but it is not working at all.

CSS

.titled-pane {   
    -fx-font-weifght: bold;
    -fx-margin: 5;
}

.titled-pane .title {
    -fx-background-color: #990000; 
    -fx-padding:2 3 3 10;
    -fx-margin: 5;
} 
Ari
  • 4,643
  • 5
  • 36
  • 52

1 Answers1

1

The answer is very basic. When instantiating VBox, declare the spacing too. Example:

VBox vbox = new VBox(5);

The codes above will give 5 pixels gap between children.

Ari
  • 4,643
  • 5
  • 36
  • 52