import java.awt.event.*;

// This appears in Core Web Programming from
// Prentice Hall Publishers, and may be freely used
// or adapted. 1997 Marty Hall, hall@apl.jhu.edu.

public class ListEvents3 extends ListEvents2 {
  public static void main(String[] args) {
    new ListEvents3();
  }

  /** Extends ListEvents2 with the twist that
   *  typing any of the letters of "JAVA" or "java"
   *  over the language list will result in "Java"
   *  being selected
   */
  public ListEvents3() {
    super();
    // Create a KeyAdapter and attach it to languageList.
    // Since this is an inner class, it has access
    // to non-public data (such as the ListEvent2's
    // protected showJava method).
    KeyAdapter javaChooser =
      new KeyAdapter() {
        public void keyPressed(KeyEvent event) {
	  int key = event.getKeyChar();
	  if ("JAVAjava".indexOf(key) != -1)
	    showJava();
	}
    };
    languageList.addKeyListener(javaChooser);
  }
}

