Add border around VBox in javafx?
Asked Answered
T

1

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");

Toyatoyama answered 10/11, 2015 at 9:36 Comment(1)
what did you try so far? Show your Approach!Cha
B
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);
Bander answered 10/11, 2015 at 9:54 Comment(1)
Have a look at this post, if you want to include your CSS code from an external file.Bander

© 2022 - 2024 — McMap. All rights reserved.