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

?????????????????????顣????????д????????????????????????????????б???????????????????????????????????????????????????б??????????????????????????????????????????????

??????????????????б?????????mediator???????????????????????????????????Mediator???????????????????????????????????????????????????????????????б?????????а????????????????б?????????е??????????????????????????????????????????Mediator??

public class Mediator{
private JawList kidList;
public Mediator(JawList klist){
kidList=klist;
}
public void loadList(Vector v){
kidList.clear();
for(int i=0;i
Swimmer sw=(Swimmer)v.elementAt(i);
kidList.add(sw.getName());
}
}
}


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

public abstract class SexButton
extends JRadioButton implements Command{
protected Swimmers swimmers;
protected Mediator med;
public SexButton(String title??Swimmers sw??Mediator md??ActionListener al){
super(title);
swimmers=sw;
med=md;
addActionListener(al);
}
public abstract void execute();
}


??????FemalButton??????????

public class FemaleButton extends SexButton{
//use the mediator to load the list
public void execute(){
Vector v=swimmers.getList(true);
med.loadList(v);
}
}


???????????????Mediator??????????б??????????????????

??????????????????????????????????????100?е?Java????????????????????ù????(Observer)??????????????JListData??????????б?????б??л???????????LawList???JListData??仯??

public class JListData extends AbstractListModel{
private Vector data;
public JListData(){
data=new Vector();
}
public int getSize(){
return data.size();
}
public Object getElementAt(int index){
return data.elementAt(index);
}
public void addElement(String s){
data.addElement(s);
fireIntervalAdded(this??data.size()-1??data.size());
}
public void removeElement(String s){
data.removeElement(s);
fireIntervalRemoved(this??0??data.size());
}
public void clear(){
int size=data.size();
data.clear();
fireIntervalRemoved(this??0??size);
}
}
public class JawList extends JScrollPane{
private JList listwindow;
private JListData listContents;
public JawList(){
listContents=new JList