home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / javax / swing / LayoutFocusTraversalPolicy.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  2.5 KB  |  109 lines

  1. package javax.swing;
  2.  
  3. import java.awt.Component;
  4. import java.awt.Container;
  5. import java.io.IOException;
  6. import java.io.ObjectInputStream;
  7. import java.io.ObjectOutputStream;
  8. import java.io.Serializable;
  9. import java.util.Comparator;
  10.  
  11. public class LayoutFocusTraversalPolicy extends SortingFocusTraversalPolicy implements Serializable {
  12.    private static final SwingDefaultFocusTraversalPolicy fitnessTestPolicy = new SwingDefaultFocusTraversalPolicy();
  13.  
  14.    public LayoutFocusTraversalPolicy() {
  15.       super(new LayoutComparator());
  16.    }
  17.  
  18.    LayoutFocusTraversalPolicy(Comparator var1) {
  19.       super(var1);
  20.    }
  21.  
  22.    public Component getComponentAfter(Container var1, Component var2) {
  23.       if (var1 != null && var2 != null) {
  24.          Comparator var3 = this.getComparator();
  25.          if (var3 instanceof LayoutComparator) {
  26.             ((LayoutComparator)var3).setComponentOrientation(var1.getComponentOrientation());
  27.          }
  28.  
  29.          return super.getComponentAfter(var1, var2);
  30.       } else {
  31.          throw new IllegalArgumentException("aContainer and aComponent cannot be null");
  32.       }
  33.    }
  34.  
  35.    public Component getComponentBefore(Container var1, Component var2) {
  36.       if (var1 != null && var2 != null) {
  37.          Comparator var3 = this.getComparator();
  38.          if (var3 instanceof LayoutComparator) {
  39.             ((LayoutComparator)var3).setComponentOrientation(var1.getComponentOrientation());
  40.          }
  41.  
  42.          return super.getComponentBefore(var1, var2);
  43.       } else {
  44.          throw new IllegalArgumentException("aContainer and aComponent cannot be null");
  45.       }
  46.    }
  47.  
  48.    public Component getFirstComponent(Container var1) {
  49.       if (var1 == null) {
  50.          throw new IllegalArgumentException("aContainer cannot be null");
  51.       } else {
  52.          Comparator var2 = this.getComparator();
  53.          if (var2 instanceof LayoutComparator) {
  54.             ((LayoutComparator)var2).setComponentOrientation(var1.getComponentOrientation());
  55.          }
  56.  
  57.          return super.getFirstComponent(var1);
  58.       }
  59.    }
  60.  
  61.    public Component getLastComponent(Container var1) {
  62.       if (var1 == null) {
  63.          throw new IllegalArgumentException("aContainer cannot be null");
  64.       } else {
  65.          Comparator var2 = this.getComparator();
  66.          if (var2 instanceof LayoutComparator) {
  67.             ((LayoutComparator)var2).setComponentOrientation(var1.getComponentOrientation());
  68.          }
  69.  
  70.          return super.getLastComponent(var1);
  71.       }
  72.    }
  73.  
  74.    protected boolean accept(Component var1) {
  75.       if (!super.accept(var1)) {
  76.          return false;
  77.       } else if (var1 instanceof JTable) {
  78.          return true;
  79.       } else if (var1 instanceof JComboBox) {
  80.          JComboBox var4 = (JComboBox)var1;
  81.          return var4.getUI().isFocusTraversable(var4);
  82.       } else {
  83.          if (var1 instanceof JComponent) {
  84.             JComponent var2 = (JComponent)var1;
  85.  
  86.             InputMap var3;
  87.             for(var3 = var2.getInputMap(0, false); var3 != null && var3.size() == 0; var3 = var3.getParent()) {
  88.             }
  89.  
  90.             if (var3 != null) {
  91.                return true;
  92.             }
  93.          }
  94.  
  95.          return fitnessTestPolicy.accept(var1);
  96.       }
  97.    }
  98.  
  99.    private void writeObject(ObjectOutputStream var1) throws IOException {
  100.       var1.writeObject(this.getComparator());
  101.       var1.writeBoolean(this.getImplicitDownCycleTraversal());
  102.    }
  103.  
  104.    private void readObject(ObjectInputStream var1) throws IOException, ClassNotFoundException {
  105.       this.setComparator((Comparator)var1.readObject());
  106.       this.setImplicitDownCycleTraversal(var1.readBoolean());
  107.    }
  108. }
  109.