Now, with the listener defined, you can modify the applet defined in Segment 872, inserting a form and form-listening augmentations:
import javax.swing.*; import java.awt.event.*; import java.util.*; public class MovieApplication extends JApplet { // Declare instance variables: private Meter meter; private JList jList; private Poster poster; private RatingPanel form; private Movie movie; private MovieData movieData; // Define constructor public MovieApplication() { // Create models getMovie(); getMovieData(); // Create and connect views to application getContentPane().add("West", getMeter()); getContentPane().add("East", new JScrollPane(getJList())); getContentPane().add("Center", getPoster()); getContentPane().add("South", getForm()); } // Define getters and setters public Meter getMeter () { if (meter == null) {setMeter(new Meter(0, 30));} return meter; } public JList getJList () { if (jList == null) {setJList(new JList());} return jList; } public Movie getMovie () { if(movie == null) {setMovie(new Movie (10, 10, 10, "On to Java"));} return movie; } public MovieData getMovieData () { if(movieData == null) {setMovieData(new MovieData ());} return movieData; } public Poster getPoster () { if (poster == null) {setPoster(new Poster());} return poster; } public RatingPanel getForm () { if (form == null) { setForm(new RatingPanel("Script", "Acting", "Direction")); } return form; } public void setMeter (Meter m) { meter = m; } public void setMovieData (MovieData m) { movieData = m; movieData.addObserver(new MovieDataObserver(this)); movieData.changed(); } public void setMovie (Movie m) { if(movie == m) {return;} if(movie instanceof Movie) {movie.deleteObservers();} if(m instanceof Movie) { movie = m; movie.addObserver(new MovieObserver(this)); movie.changed(); } } public void setJList (JList j) { jList = j; jList.addListSelectionListener(new MovieListListener(this)); } public void setPoster (Poster p) { poster = p; } public void setForm (RatingPanel f) { form = f; form.addPropertyChangeListener(new RatingPanelListener(this)); } }