您确实应该将它们放入数组或Collection中,以便可以在它们上循环。例如。
List<JCheckBox> allCheckBoxes = new ArrayList<JCheckBox>()allCheckboxes.add(new JCheckBox());
等等
如果您将所有这些复选框都声明为成员,则没有任何借口将它们放在列表中。
在此期间,您可以在for循环中使用躲猫猫(如果所有复选框都在同一面板上)
boolean allSelected = true;for(Component component : myPanel.getComponents()) { if(component instanceof JCheckBox) { allSelected &= ((JCheckBox)component).isSelected(); }}我建议您先阅读有关Java数组和集合的信息,然后再继续
http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.html
http://java.sun.com/docs/books/tutorial/collections/index.html



