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

  1. package java.awt;
  2.  
  3. import java.io.Serializable;
  4.  
  5. class FocusManager implements Serializable {
  6.    Container focusRoot;
  7.    Component focusOwner;
  8.    static final long serialVersionUID = 2491878825643557906L;
  9.  
  10.    FocusManager(Container var1) {
  11.       this.focusRoot = var1;
  12.    }
  13.  
  14.    private void activateFocus() {
  15.       boolean var1 = false;
  16.       if (this.focusOwner != null) {
  17.          if (!(var1 = this.assignFocus(this.focusOwner, false))) {
  18.             var1 = this.focusNext(this.focusOwner);
  19.          }
  20.       } else {
  21.          var1 = this.focusForward(this.focusRoot);
  22.       }
  23.  
  24.       if (!var1) {
  25.          this.focusRoot.requestFocus();
  26.       }
  27.  
  28.    }
  29.  
  30.    synchronized void setFocusOwner(Component var1) {
  31.       this.focusOwner = var1;
  32.    }
  33.  
  34.    Component getFocusOwner() {
  35.       return this.focusOwner;
  36.    }
  37.  
  38.    boolean focusNext() {
  39.       return this.focusNext(this.focusOwner);
  40.    }
  41.  
  42.    boolean focusNext(Component var1) {
  43.       Object var3 = this.focusRoot.getTreeLock();
  44.       synchronized(var3){}
  45.  
  46.       boolean var13;
  47.       try {
  48.          Object var5 = var1;
  49.          Container var7;
  50.          if (var1 != null && var1.parent != null) {
  51.             do {
  52.                boolean var6 = false;
  53.                var7 = ((Component)var5).parent;
  54.  
  55.                for(int var9 = 0; var9 < var7.ncomponents; ++var9) {
  56.                   Component var8 = var7.component[var9];
  57.                   if (var6) {
  58.                      if (this.assignFocus(var8)) {
  59.                         var13 = true;
  60.                         return var13;
  61.                      }
  62.  
  63.                      if (var8 instanceof Container && var8.isVisible() && var8.isEnabled() && this.focusForward((Container)var8)) {
  64.                         var13 = true;
  65.                         return var13;
  66.                      }
  67.                   } else if (var8 == var5) {
  68.                      var6 = true;
  69.                   }
  70.                }
  71.  
  72.                var5 = var7;
  73.             } while(var7 != this.focusRoot && var7.parent != null);
  74.          }
  75.  
  76.          if (!this.focusForward(this.focusRoot)) {
  77.             var13 = false;
  78.             return var13;
  79.          }
  80.  
  81.          var13 = true;
  82.       } catch (Throwable var11) {
  83.          throw var11;
  84.       }
  85.  
  86.       return var13;
  87.    }
  88.  
  89.    boolean focusPrevious() {
  90.       return this.focusPrevious(this.focusOwner);
  91.    }
  92.  
  93.    boolean focusPrevious(Component var1) {
  94.       Object var3 = this.focusRoot.getTreeLock();
  95.       synchronized(var3){}
  96.  
  97.       boolean var13;
  98.       try {
  99.          Object var5 = var1;
  100.          Container var7;
  101.          if (var1 != null && var1.parent != null) {
  102.             do {
  103.                boolean var6 = false;
  104.                var7 = ((Component)var5).parent;
  105.  
  106.                for(int var9 = var7.ncomponents - 1; var9 >= 0; --var9) {
  107.                   Component var8 = var7.component[var9];
  108.                   if (var6) {
  109.                      if (this.assignFocus(var8)) {
  110.                         var13 = true;
  111.                         return var13;
  112.                      }
  113.  
  114.                      if (var8 instanceof Container && var8.isVisible() && var8.isEnabled() && this.focusBackward((Container)var8)) {
  115.                         var13 = true;
  116.                         return var13;
  117.                      }
  118.                   } else if (var8 == var5) {
  119.                      var6 = true;
  120.                   }
  121.                }
  122.  
  123.                var5 = var7;
  124.             } while(var7 != this.focusRoot);
  125.          }
  126.  
  127.          if (!this.focusBackward(this.focusRoot)) {
  128.             var13 = false;
  129.             return var13;
  130.          }
  131.  
  132.          var13 = true;
  133.       } catch (Throwable var11) {
  134.          throw var11;
  135.       }
  136.  
  137.       return var13;
  138.    }
  139.  
  140.    boolean assignFocus(Component var1) {
  141.       return this.assignFocus(var1, true);
  142.    }
  143.  
  144.    synchronized boolean assignFocus(Component var1, boolean var2) {
  145.       if (!var1.isVisible() || !var1.isEnabled() || var2 && !var1.isFocusTraversable()) {
  146.          return false;
  147.       } else {
  148.          var1.requestFocus();
  149.          return true;
  150.       }
  151.    }
  152.  
  153.    synchronized boolean focusForward(Container var1) {
  154.       for(int var2 = 0; var2 < var1.ncomponents; ++var2) {
  155.          Component var3 = var1.component[var2];
  156.          if (this.assignFocus(var3)) {
  157.             return true;
  158.          }
  159.  
  160.          if (var3 instanceof Container && var3.isVisible() && var3.isEnabled() && this.focusForward((Container)var3)) {
  161.             return true;
  162.          }
  163.       }
  164.  
  165.       return false;
  166.    }
  167.  
  168.    synchronized boolean focusBackward(Container var1) {
  169.       for(int var2 = var1.ncomponents - 1; var2 >= 0; --var2) {
  170.          Component var3 = var1.component[var2];
  171.          if (this.assignFocus(var3)) {
  172.             return true;
  173.          }
  174.  
  175.          if (var3 instanceof Container && var3.isVisible() && var3.isEnabled() && this.focusBackward((Container)var3)) {
  176.             return true;
  177.          }
  178.       }
  179.  
  180.       return false;
  181.    }
  182. }
  183.