import java.awt.event.*; /** * Simple adapter class. * When a key comes in, tell your smarts about it. * Contract: AWT will call keyTyped, and I will tell my smarts which key. */ public class SimpleKeyListener extends KeyAdapter { /** * Who to tell. */ private AlphaSmarts smarts; /** * Remember who to tell. */ public SimpleKeyListener( AlphaSmarts smarts ) { this.smarts = smarts; } /** * Tell (which char). * @param e The event (holding the char). */ public void keyTyped( KeyEvent e ) { this.smarts.handleChar( e.getKeyChar() ); } }