import java.awt.*; import java.awt.event.*; public class KeyCounterAdapter extends KeyAdapter { protected KeyCounter inflexibleClient; //------------------------------------------------------------------- // KeyCounterAdapter constructor //------------------------------------------------------------------- public KeyCounterAdapter(KeyCounter inflexibleClient, Component keyEventSource) { this.inflexibleClient = inflexibleClient; // register with key event source on behalf of client object keyEventSource.addKeyListener(this); } //------------------------------------------------------------------- // keyTyped() is the method required by the event source, so here // we transform (=adapt) the event to what the client expects. //------------------------------------------------------------------- public void keyTyped(KeyEvent keyEvent) { inflexibleClient.hereAnotherKey( keyEvent.getKeyChar() ); } } // End of Class KeyCounterAdapter