Java PASS方法作为参数
public void setAllComponents(Component[] myComponentArray, Method myMethod) {
for (Component leaf : myComponentArray) {
if (leaf instanceof Container) { //recursive call if Container
Container node = (Container) leaf;
setAllComponents(node.getComponents(), myMethod);
} //end if node
myMethod(leaf);
} //end looping through components}setAllComponents(this.getComponents(), changeColor());setAllComponents(this.getComponents(), changeSize());
白猪掌柜的
相关分类