Javafx 2.0 add border to label

I have a label with the style of the "test" class in my javafx application. I wanted to add a white border around this label, so in the css file I tried:

-fx-border-width: 2; -fx-border-color: white; 

but this did not work, so I tried to add:

 -fx-border-style: solid; 

but that didn't work either, after javafx css link I didn't find anything useful. what am I doing wrong?

+6
source share
1 answer

Can you try:

 System.out.println(label); 

it should print something like

 Label@1858c80c [styleClass=label] 

Is your css class print too after styleclass = label ...?
Or you can remove the css tag class and try to set the shortcut style in the code directly:

 label.setStyle("-fx-border-color: white;"); 

if you see the changes, you may inadvertently override the css class definition in the css file. Check it out.

+7
source

Source: https://habr.com/ru/post/915483/


All Articles