How to change the color of text in javafx TextField?

后端 未结 2 1183
悲&欢浪女
悲&欢浪女 2021-02-11 16:38

I want to change font color in TextField .I found -fx-background-color , -fx-border-color for changing the color of background and border but nothing f

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-11 17:10

    Setting the -fx-text-fill works for me.

    See below:

    if (passed) {
        resultInfo.setText("Passed!");
        resultInfo.setStyle("-fx-text-fill: green; -fx-font-size: 16px;");
    } else {
        resultInfo.setText("Failed!");
        resultInfo.setStyle("-fx-text-fill: red; -fx-font-size: 16px;");
    }
    

提交回复
热议问题