JavaFx中两例有趣的代码
1.
keyBackground.fillProperty().bind(
Bindings.when(pressedProperty)
.then(Color.RED)
.otherwise(Bindings.when(keyNode.focusedProperty())
.then(Color.LIGHTGRAY)
.otherwise(Color.WHITE)));
2.寻找下个节点
private Node getNextNode(Parent parent, Node node) {
final Iterator<Node> childIterator =
parent.getChildrenUnmodifiable().iterator();
while (childIterator.hasNext()){
if(childIterator.next() == node){
return childIterator.hasNext() ? childIterator.next()
:null;
}
}
return null;
}
3.寻找上一个节点
private Node getPreviousNode(Par