javafx 2.0 adding border to Label

31,832

Can you try:

System.out.println(label);

it should print something like

Label@1858c80c[styleClass=label]

Is your css class printing too after styleClass=label ... ?
Or can you remove css class of the label and try setting the label style in code directly by:

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

if you can see the changes then maybe you are unintentionally overriding css class definiton in css file. Check it.

Share:
31,832
bennyl
Author by

bennyl

Updated on May 11, 2020

Comments

  • bennyl
    bennyl almost 4 years

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

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

    but that didnt worked so then i tried to add:

    -fx-border-style: solid;
    

    but that didnt worked either, following javafx css reference I didn't find anything useful. what am I doing wrong?

  • bennyl
    bennyl almost 12 years
    as you suggested - using the label.setStyle("-fx-border-color: white;"); directly shows the border, BUT in the css i am using -fx-text-fill: blue; and it affecting the label forecolor so why don't the border on the same css selector affect the label too?
  • Uluk Biy
    Uluk Biy almost 12 years
    It should be affected. Are you editing the right css file. Try to clean and rebuild the app. Try to change foreground of the label to a different color other than blue to check if the label is taking correct css file and class.
  • bennyl
    bennyl almost 12 years
    cleaning and building the app worked! what an awful waste of time, thank you very much for all your help!