Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 214
Francisco Avatar asked Dec 22 '16 22:12

Francisco


People also ask

How do you change the color of a TextField in JavaFX?

If you are designing your Javafx application using SceneBuilder then use -fx-text-fill (if not available as option then write it in style input box) as style and give the color you want,it will change the text color of your Textfield .

How do you add a text field in JavaFX?

Creating a Text FieldLabel label1 = new Label("Name:"); TextField textField = new TextField (); HBox hb = new HBox(); hb. getChildren(). addAll(label1, textField); hb. setSpacing(10);

Where is modena Css?

then simply take a look at the default CSS stylesheet that ships with JavaFX. The file is called modena. css and can be found in the jfxrt. jar file in this location: com/sun/javafx/scene/control/skin/modena/.


1 Answers

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) */
}
like image 197
Bo Halim Avatar answered Sep 20 '22 12:09

Bo Halim