JavaFX style class won't refresh

前端 未结 5 1205
说谎
说谎 2021-02-08 05:08

I\'m adding a style class to an node if it\'s selected and then remove it if I select other item. Even if I remove the style class the style wont refresh so it wont go back to n

5条回答
  •  广开言路
    2021-02-08 05:51

    6 Years laters the bug is still there, here is a simpler way to go, specially if you won't want to mess with the other classes :

    int indexOf = textField.getStyleClass().indexOf(INVALID_CLASS);
    if(indexOf != -1){
        textField.getStyleClass().remove(indexOf);
    }
    

    Why this works ? Because the list used for StyleClass which is a TrackableObservablieList inherits from a hierarchy where the remove(index) does fire changes where the remove(Object) does not.

提交回复
热议问题