JavaFX Text Double Underline Spacing


Question

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

1
1
9/17/2014 8:29:00 AM

Accepted Answer

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.

4
5/23/2017 12:14:21 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon