JavaFX style class won't refresh

前端 未结 5 1170
说谎
说谎 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:56

    At least for Java 8, this works now. But instead of doing what the OP did, I would achieve the same like this:

    admin_category_label.getStyleClass().remove("selected");
    admin_category_label.getStyleClass().add("clear");
    

    Looks a bit cleaner.

    Remember, that your CSS selectors need to look like this:

    .selected {
        /* Styling attributes... */
    }
    
    .clear {
        /* Styling attributes... */
    }
    

提交回复
热议问题