JavaFX Text Double Underline Spacing

10,781

You can adjust the position of the border with CSS:

.double-underline {
    -fx-border-color: black;
    -fx-border-width: 0 0 1 0;
    -fx-underline: true;

    -fx-padding: 0 0 -1 0;
}

EDIT: As Uluk Biy says, the above snippet will join the border to the actual underline. So this will do what you want:

.double-underline {
    -fx-border-color: black, transparent, black;
    -fx-border-width: 0 0 1 0, 0 0 1 0, 0 0 1 0;
    -fx-border-insets: 0 0 1 0, 0 0 2 0, 0 0 3 0;
}

Instead of using an underlined label, configure a double border, and just play with the insets.

Share:
10,781
Gillardo
Author by

Gillardo

Updated on June 14, 2022

Comments

  • Gillardo
    Gillardo almost 2 years

    I have a label in JavaFX application that i need to apply a double underline too. I know this aint possible to do with a basic property, but instead i have applied the following css to the label, which gives it a "effect" of a double underline

    .double-underline {
        -fx-border-color: #FFFFFF;
        -fx-border-width: 0 0 1 0;
        -fx-underline: true;
    }
    

    Now this does give me the effect i want, but i need to if possible, increase the spacing between the text and the actual underline. How can i do this?

    This would be easier if there was a "double" border style that i could apply, but there isnt that i know of

    Here is what it looks like now

    javafx underline image before

    and i would like it too look more like this

    javafx underline image after

    Thanks in advance