Home Segments Top Top Previous Next

934: Mainline

The definition shown in Segment 932 enables information to flow from the form view to the currently selected movie model, but you still must do a little more work to get information to flow from the currently selected movie model to the form view. In particular, you need to modify the movie observer, previously defined in Segment 871, such that the update method calls the form's setters:

import java.util.*;
public class MovieObserver implements Observer {
 private MovieApplication applet;
 public MovieObserver (MovieApplication a) {
  applet = a;
 }
 public void update (Observable observable, Object object) {
  applet.getMeter().setValue(applet.getMovie().rating());
  applet.getMeter().setTitle(applet.getMovie().getTitle());
  applet.getPoster().setImageFile(applet.getMovie().getPoster());
  applet.getForm().setValue1(applet.getMovie().getScript());    
  applet.getForm().setValue2(applet.getMovie().getActing());    
  applet.getForm().setValue3(applet.getMovie().getDirection()); 
 }                                                       
}