home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1999 April / DPPCPRO0499.ISO / April / Notes / 50b2wic.exe / DATA1.CAB / NotesProgramFilesJavaSupport / rt.jar / sun / awt / FocusingTextField.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-04-23  |  1.1 KB  |  56 lines

  1. package sun.awt;
  2.  
  3. import java.awt.Event;
  4. import java.awt.TextComponent;
  5. import java.awt.TextField;
  6.  
  7. public class FocusingTextField extends TextField {
  8.    TextField next;
  9.    boolean willSelect;
  10.  
  11.    public FocusingTextField(int var1) {
  12.       super("", var1);
  13.    }
  14.  
  15.    public FocusingTextField(int var1, boolean var2) {
  16.       this(var1);
  17.       this.willSelect = var2;
  18.    }
  19.  
  20.    public void setWillSelect(boolean var1) {
  21.       this.willSelect = var1;
  22.    }
  23.  
  24.    public boolean getWillSelect() {
  25.       return this.willSelect;
  26.    }
  27.  
  28.    public void setNextField(TextField var1) {
  29.       this.next = var1;
  30.    }
  31.  
  32.    public boolean gotFocus(Event var1, Object var2) {
  33.       if (this.willSelect) {
  34.          ((TextComponent)this).select(0, ((TextComponent)this).getText().length());
  35.       }
  36.  
  37.       return true;
  38.    }
  39.  
  40.    public boolean lostFocus(Event var1, Object var2) {
  41.       if (this.willSelect) {
  42.          ((TextComponent)this).select(0, 0);
  43.       }
  44.  
  45.       return true;
  46.    }
  47.  
  48.    public void nextFocus() {
  49.       if (this.next != null) {
  50.          this.next.requestFocus();
  51.       }
  52.  
  53.       super.nextFocus();
  54.    }
  55. }
  56.