javafx:标记一些分页控制号

时间:2018-04-24 16:48:33

标签: javafx pagination

是否可以标记一些分页控件按钮以指示页面包含重要内容?
示例:更改按钮5和7的背景颜色 非常感谢。

1 个答案:

答案 0 :(得分:0)

    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 } 
相关问题