Javafx:标记一些分页控制号



是否可以标记某些分页控制按钮指示页面包含一些重要的内容?

示例:更改按钮5和7的背景颜色
非常感谢。

    public void colorImportantIndicatorButton(Parent node) {
    int i = 0;
     for (Node subNode : node.getChildrenUnmodifiable()) {
       if (subNode.getClass().getSimpleName().equals("IndicatorButton")) {
          subNode.setId("IB" + i); 
          if ( isImportant(i) ) { 
            subNode.setStyle("-fx-background-color:red;"); 
          } 
         i++;
        } 
        if (subNode instanceof Parent) {
           colorImportantIndicatorButton((Parent) subNode); 
        } 
      } 
    } 
    public boolean isImportant(int index){ // return true or false } 

最新更新