Need to customize combobox in javafx with xml data

后端 未结 1 906
感动是毒
感动是毒 2021-01-24 21:47

I need to display the javafx tree table with values read from XML file. I am able to do it as shown below,

I am able to add color to the combo box as shown

相关标签:
1条回答
  • 2021-01-24 21:49

    Your issue seems to be in your update item.

    You are checking that it's not empty, then if empty set back to ""...

    if(!empty) {
        if (status == null || empty) {
             setStyle("");
        }
        etc...
    

    Just remove the outer check - you don't the our if(!empty){}

    Just use this:

    if (status == null || empty) {
       setStyle("");
    }
    else if (clmStatus.equals("Passed")) {
        setTextFill(Color.BLACK);
        setStyle("-fx-background-color: green");
        setText(clmStatus);
    } else if (clmStatus.equals("Failed")){
        setTextFill(Color.BLACK);
        setStyle("-fx-background-color: red");
        setText(clmStatus);
    } else if (clmStatus.equals("NotRelevant")){
        setTextFill(Color.BLACK);
        setStyle("-fx-background-color: blue");
        setText(clmStatus);
    

    }

    0 讨论(0)
提交回复
热议问题