home *** CD-ROM | disk | FTP | other *** search
/ Java Certification Exam Guide / McGrawwHill-JavaCertificationExamGuide.iso / pc / Web Links and Code / ans / chap15 / exer1503 / TFHandler.java
Encoding:
Text File  |  1997-04-20  |  409 b   |  17 lines

  1. class TFHandler extends KeyAdapter implements FocusListener {
  2.  
  3.    public void focusGained(FocusEvent e) {
  4.       e.getComponent().setBackground(Color.red);
  5.    }
  6.  
  7.    public void focusLost(FocusEvent e) {
  8.       e.getComponent().setBackground(Color.white);
  9.    }
  10.  
  11.    public void keyTyped(KeyEvent e) {
  12.       if (e.getKeyChar() == '!')
  13.          e.getComponent().setBackground(Color.yellow);
  14.    }
  15.  
  16. }
  17.