Yurttas/PL/OOL/Java/F/09/02/01/00/ShowSeeding00.java

 1import java.awt.*;
 2import javax.swing.*;
 3import javax.swing.event.*;
 4import java.util.*;
 5
 6public class ShowSeeding00 extends JxFrame
 7                           implements ListSelectionListener { 
 8
 9  private JawtList evList,
10                   swList;
11  private Vector events;
12
13  public ShowSeeding00() {
14    super("Factory Method Seeding");
15    events =  new Vector();
16
17    JPanel jp = new JPanel();
18    getContentPane().add(jp);
19    jp.setLayout(new GridLayout(1,2));
20
21    evList = new JawtList(20);
22    swList = new JawtList(20);
23    jp.add(evList);
24    jp.add(swList);
25    evList.addListSelectionListener(this);
26
27    events.addElement(new TimedFinalEvent("500free.txt", 6));
28    evList.add("500 Free");
29    events.addElement(new PrelimEvent("100free.txt", 6));
30    evList.add("100 Free");
31  
32    setSize(new Dimension(300,200));
33    setVisible(true);
34  }
35
36  public void valueChanged(ListSelectionEvent e) {
37    swList.clear();
38    int index = evList.getSelectedIndex();
39    System.out.println("index="+index);
40    Event ev = (Event)events.elementAt(index);
41    Seeding sd = ev.getSeeding();
42    Enumeration enum  =sd.getSwimmers();
43    while(enum.hasMoreElements()) {
44      Swimmer sw = (Swimmer)enum.nextElement();
45      swList.add(sw.getHeat()+" "+sw.getLane()+" "+sw.getName()+" "+sw.getTime());
46    }
47  }
48
49  static public void main(String argv[]) {
50    new ShowSeeding00();
51  }
52
53}