jdk1.5.0目录\demo\jfc\SwingSet2\src÷SwingSet2.java第1303行,
下面片段代码中最后一个for语句,大家看看是不是很怪,不知道“:”起什么作用的?望大家解答
class DragSupportAction extends AbstractAction {
protected DragSupportAction() {
super("DragSupport Control");
}
public void actionPerformed(ActionEvent e) {
boolean dragEnabled = ((JCheckBoxMenuItem)e.getSource()).isSelected();
if (isApplet()) {
setDragEnabled(dragEnabled);
} else {
for (SwingSet2 ss : swingSets) {
ss.setDragEnabled(dragEnabled);
}
}
}
}
下面片段代码中最后一个for语句,大家看看是不是很怪,不知道“:”起什么作用的?望大家解答
class DragSupportAction extends AbstractAction {
protected DragSupportAction() {
super("DragSupport Control");
}
public void actionPerformed(ActionEvent e) {
boolean dragEnabled = ((JCheckBoxMenuItem)e.getSource()).isSelected();
if (isApplet()) {
setDragEnabled(dragEnabled);
} else {
for (SwingSet2 ss : swingSets) {
ss.setDragEnabled(dragEnabled);
}
}
}
}
对于集合遍历用for的简化,要不得写一堆代码
难怪书上总找不到