使用JavaFX,我希望显示一个带有定义的背景颜色的Label(当禁用时,我的Label的背景变成透明),我尝试了下面的代码,但仍然无法实现...你有什么提示吗?-另一个线程告诉我要做一个setEditable(false)
,但这种方法在我的情况下不合适。
FXML:
<Label styleClass="disable_backgrounded" layoutX="32.0" layoutY="23.0" prefHeight="25.0"
style="-fx-background-color: rgb(252,252,252);-fx-padding: 5px;" text="General" textFill="#aa0000">
<font>
<Font name="System Bold" size="14.0"/>
</font>
</Label>
CSS:
.disable_backgrounded:disabled {
-fx-background-color: rgb(252,252,252);
}