如何更改TextField的背景颜色而不更改javafx中的边框? [英] How do you change the background color of a TextField without changing the border in javafx?

查看:155
本文介绍了如何更改TextField的背景颜色而不更改javafx中的边框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将TextFieldcolorBox0的背景颜色更改为value0,但它摆脱了边框。

以下是我的代码的简化版本:

I am trying to change the background color of my TextField "colorBox0" to "value0" but it gets rid of the border.
Here is a simplified version of my code:

   static Paint value0 = Paint.valueOf("FFFFFF");
   TextField colorBox0;
   colorBox0.setBackground(new Background(new BackgroundFill(value0, CornerRadii.EMPTY, Insets.EMPTY)));

非常感谢任何帮助

谢谢

Any help is very much appreciated
Thank you

推荐答案

我发现你可以通过使用to string方法和子串方法来构造一个字符串和变量的css代码字符串,如下所示:

I found that you can construct a string of css code out of a string and a variable by using the to string method and the substring method like this:

colorBox0
.setStyle("-fx-control-inner-background: #"+value0.toString().substring(2));

这篇关于如何更改TextField的背景颜色而不更改javafx中的边框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆