1public void setAllComponents(Component[] myComponentArray, Consumer<Component> myMethod) {
2 for (Component leaf : myComponentArray) {
3 if (leaf instanceof Container) {
4 Container node = (Container) leaf;
5 setAllComponents(node.getComponents(), myMethod);
6 }
7 myMethod.accept(leaf);
8 }
9}
10
1setAllComponents(this.getComponents(), this::changeColor);
2setAllComponents(this.getComponents(), this::changeSize);
3
1public interface Function4<A, B, C, D, R> {
2
3 R apply(A a, B b, C c, D d);
4}
5