home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 March / pcp161a.iso / handson / files / copyjava.exe / com / sun / java / swing / plaf / basic / BasicComboBoxUI$FocusRequestHelper.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-02-26  |  2.3 KB  |  76 lines

  1. package com.sun.java.swing.plaf.basic;
  2.  
  3. import com.sun.java.swing.Timer;
  4. import java.awt.Component;
  5. import java.awt.Container;
  6. import java.awt.Window;
  7. import java.awt.event.ActionEvent;
  8. import java.awt.event.ActionListener;
  9. import java.awt.event.WindowEvent;
  10. import java.awt.event.WindowListener;
  11. import java.io.Serializable;
  12.  
  13. class BasicComboBoxUI$FocusRequestHelper implements WindowListener, ActionListener, Serializable {
  14.    Window window = null;
  15.    Component component;
  16.    Timer timer;
  17.  
  18.    BasicComboBoxUI$FocusRequestHelper(Component var1) {
  19.       this.component = var1;
  20.  
  21.       for(Container var2 = var1.getParent(); var2 != null; var2 = ((Component)var2).getParent()) {
  22.          if (var2 instanceof Window) {
  23.             this.window = (Window)var2;
  24.             break;
  25.          }
  26.       }
  27.  
  28.       if (this.window != null) {
  29.          this.window.addWindowListener(this);
  30.       }
  31.    }
  32.  
  33.    public void windowOpened(WindowEvent var1) {
  34.    }
  35.  
  36.    public void windowClosing(WindowEvent var1) {
  37.    }
  38.  
  39.    public void windowClosed(WindowEvent var1) {
  40.       this.window.removeWindowListener(this);
  41.    }
  42.  
  43.    public void windowIconified(WindowEvent var1) {
  44.    }
  45.  
  46.    public void windowDeiconified(WindowEvent var1) {
  47.    }
  48.  
  49.    public void windowActivated(WindowEvent var1) {
  50.       this.window.removeWindowListener(this);
  51.       this.startTimer();
  52.    }
  53.  
  54.    public void windowDeactivated(WindowEvent var1) {
  55.    }
  56.  
  57.    void startTimer() {
  58.       this.timer = new Timer(20, this);
  59.       this.timer.start();
  60.    }
  61.  
  62.    public void actionPerformed(ActionEvent var1) {
  63.       if (this.timer != null) {
  64.          this.timer.stop();
  65.       }
  66.  
  67.       if (this.component != null) {
  68.          this.component.requestFocus();
  69.       }
  70.  
  71.       this.component = null;
  72.       this.timer = null;
  73.       this.window = null;
  74.    }
  75. }
  76.