???????Java??ó???????
???????????? ???????[ 2012/8/24 9:48:12 ] ????????
??????????????????汾??????????????????飬????????Щ???к????????????????????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);
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11