简体   繁体   English

如何在JavaFX中将文本字段的选择边框设置为某种颜色?

[英]How to set the selection border of a Textfield a certain color in JavaFX?

I'm trying to create a Textfield in JavaFX. 我正在尝试在JavaFX中创建一个Textfield。 I would like to use a custom color for the selection of the Textfield. 我想使用自定义颜色来选择Textfield。 I'm not sure what the property is, so I can only explain it this way. 我不确定该属性是什么,因此只能以这种方式进行解释。 When you select it by default, a sky-bluish color shows up on the border. 当您默认选择它时,边框上会显示天蓝色。 How do I remove that completely, or set it to a custom color? 如何将其完全删除,或将其设置为自定义颜色? Here is my CSS code: 这是我的CSS代码:

.login-info {
-fx-border-style: solid;

-fx-accent: red; }

The textfield uses -fx-background-color: property to achive that. 文本字段使用-fx-background-color:属性来实现该目的。 So by overriding 因此,通过覆盖

.textfield:focused{
   -fx-background-color : yellow,white;
   -fx-background-insets: 0,3px;
}

will make the border color yellow, instead of sky-blue when you click on it. 单击将使边框颜色变为黄色,而不是天蓝色。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM