??????????????????汾??????????????????飬????????Щ???к????????????????????Vector?????????????????????????????????????????????????????isFemal???????????????????????????????????е????????

??????????JAVA?鼮???????SWING???????????????JAVA??????????????????????????????????JFrame?????JPanel?????????????飺?????????????????????????????????ж????????????????????£??????????????????????????????????????????????????????????е????????????????JAVA????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????£????????JavaPro???????????????????????

?????????????????????????????????????????????????

????????????????????д?????ü?????????????????б???????????????????Female?????????????????????????????????Male??????????????к????????

??????????????汾??????????????????飬????????Щ???к????????????????????Vector?????????????????????????????????????????????????????isFemal???????????????????????????????????е????????????????????????????????Swimmer??

public class Swimmer{
private String name;
private int age;
private String club;
private boolean female;
public Swimmer(String name??int age??String club??boolean female){
this.name=name;
this.age=age;
this.club=club;
this.female=female;
}
public boolean isFemale(){
return female;
}
public String getName(){
return name;
}
public int getAge(){
return age;
}
public String getClub(){
return club;
}
}


????????????????????????????б??е???Щ???????????????????????????????????????????????????????Swimmers?????????????????????????getList()???????????в??????????????????к??????????

//get a vector of swimmers who are (female)
public Vector getList(boolean female){
Vector v=new Vector();
for(int i=0;i
Swimmer swm=(Swimmer)kids.elementAt(i);
if(swm.isFemal()==female) v.add(swm);
}
return v;
}


?????????????????????????????getList()???????????????б??

?????????????????????е??????????????????????Щ??????????????????????????????????????????????????????????????????????????

public void actionPerformed(ActionEvent e){
//listen for button clicks and do the right thing
Object obj=e.getSource();
if(obj==female) loadFemales();
if(obj==male) loadMales();
if(obj==both) loadBoth();
}
private void loadFemales(){
//display female swimmers
Vector v=swimmers.getList(true);
loadList(v);
}
private void loadMales(){
//display male swimmers
Vector v=swimmers.getList(false);
loadList(v);
}