8

IS it possible to add a borderline around a whole content of a VBox in Javafx?

Meaning i have added a lot of components already in tis VBox but want to have a border around it?

So if i have the css file like this:

#vbox_style {
    -fx-border-color: black;
    -fx-border-insets: 5;
    -fx-border-width: 3;
    -fx-border-style: dashed;
 }

How could i get this Resource, where do the file need to be located to use method as: myBox.setId("vbox_style");

Mikael
  • 633
  • 2
  • 8
  • 15

1 Answers1

11

You can set a custom CSS style on the VBox:

String cssLayout = "-fx-border-color: red;\n" +
                   "-fx-border-insets: 5;\n" +
                   "-fx-border-width: 3;\n" +
                   "-fx-border-style: dashed;\n";

VBox yourBox = new VBox();   
yourBox.setStyle(cssLayout);
user1438038
  • 5,821
  • 6
  • 60
  • 94
  • Have a look at [this post](http://stackoverflow.com/questions/22043650/what-is-wrong-with-my-syntax-calling-a-stylesheet-css-from-an-fxml-file/22048338#22048338), if you want to include your CSS code from an external file. – user1438038 Nov 10 '15 at 10:26