import java.awt.*;
import java.util.*;
import java.awt.swing.*;
import java.awt.swing.event.*;
public class MovieApplet extends JApplet {
 Movie movie;
 Vector movieVector;
 MeterCanvas meterCanvas = new MeterCanvas();
 VectorChoiceList choiceList = new VectorChoiceList();
 ImageCanvas imageCanvas = new ImageCanvas(); 
 FormPanel formPanel = new FormPanel();                 
 public void init () {
  getContentPane().add("West", meterCanvas); 
  getContentPane().add("Center", new JScrollPane(choiceList));
  getContentPane().add("East", imageCanvas); 
  getContentPane().add("South", formPanel);             
  setMovieVector("general.movies");
  choiceList.addListSelectionListener(new LocalListener()); 
 }
 public void setMovieVector (String file) {      
  movieVector = MovieAuxiliaries.readMovieFile(file);    
  choiceList.setChoices(movieVector);                   
 }                                               
 public void setMovie(int n) { 
  if (0 <= n & n < movieVector.size()) { 
   movie = (Movie)movieVector.elementAt(n); 
   meterCanvas.attachObservable(movie); 
   imageCanvas.attachObservable(movie); 
   formPanel.attachObservable(movie);                  
   movie.changed(); 
  } 
 } 
 class LocalListener implements ListSelectionListener {
  public void valueChanged(ListSelectionEvent e) { 
   setMovie(choiceList.getSelectedIndex());
  } 
 } 
}
