How to change the glow outline color of a focused text field in JavaFX?

Francisco picture Francisco · Dec 22, 2016 · Viewed 9k times · Source

After alot of browsing I haven't yet found a solution to this.

I'm trying to change this really light blue-ish border color around the TextFiedl (when it's selected).


The closest I've been to was with this: enter image description here

.text-field {
    -fx-faint-focus-color: red;
}

But I get this result:

enter image description here

A really strong tone of red (the complete opposite of that soft border), that also looks thicker than the original one.


So, how can I change just the color, so that instead of a very light blue I'd be able to get, say, a very light red, whilst keeping the thickness/overall feel of the original glow?

Answer

Bo Halim picture Bo Halim · Dec 22, 2016

Have you tried to reduce the alpha :

.text-field:focused{
    -fx-faint-focus-color: transparent;
    -fx-focus-color:rgba(255,0,0,0.2); /* here rgba (corrected) */
}