JavaFX TextField CSS

How to create JavaFX TextField like Android TextField using JavaFX CSS?

For instance: Android TextField

I tried a lot of FX css, but did not get this kind. Here http://jsfiddle.net/QKm37/ CSS exists for the HTML input type, but it is not applicable in JavaFX SceneBuilder.

For example: /** Not Exist in JavaFX **/

-fx-border: none;

-fx-background: bottom left linear-gradient(#a9a9a9, #a9a9a9) no-repeat, bottom center linear-gradient(#a9a9a9, #a9a9a9) repeat-x, bottom right linear-gradient(#a9a9a9, #a9a9a9) no-repeat;

+7
source share
2 answers

Try this in your CSS file:

 .text-field { -fx-background-color: #a9a9a9 , white , white; -fx-background-insets: 0 -1 -1 -1, 0 0 0 0, 0 -1 3 -1; } .text-field:focused { -fx-background-color: #a9a9a9 , white , white; -fx-background-insets: 0 -1 -1 -1, 0 0 0 0, 0 -1 3 -1; } 
+14
source

There is a library for material components called jfoenix, which basically gives javafx components the style of the material. Java material library after adding the library just create an instance of JFXTextField () example of android styled textfield

0
source

Source: https://habr.com/ru/post/978387/


All Articles