JavaFX 文本字段 CSS
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27014609/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JavaFX TextField CSS
提问by Gaurav Kumar
How to create JavaFX TextField look like Android TextField using JavaFX CSS ?
如何使用 JavaFX CSS 创建看起来像 Android TextField 的 JavaFX TextField?
For example :
例如 :
I have tried lots of FX css but not achieved look like that . Here http://jsfiddle.net/QKm37/CSS exist for HTML input type but it is not applicable in JavaFX SceneBuilder .
我已经尝试了很多 FX css,但没有达到那样的效果。这里http://jsfiddle.net/QKm37/CSS 存在于 HTML 输入类型,但它不适用于 JavaFX SceneBuilder 。
For example : /** Not Exist in JavaFX **/
例如 : /** Not Exist in JavaFX **/
-fx-border: none;
-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;
-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;
采纳答案by Mailkov
Try this in your CSS file:
在你的 CSS 文件中试试这个:
.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;
}
回答by shavar
There is a library for material components called jfoenix, it basically give
javafx components a material style.
java material libraryafter adding the library just instantiate a JFXTextField()
有一个名为 jfoenix 的材质组件库,它基本上为 javafx 组件提供了材质样式。
添加库后的java材料库只需实例化一个JFXTextField()