< prev index next >

src/java.desktop/share/classes/java/awt/ContainerOrderFocusTraversalPolicy.java

Print this page


   1 /*
   2  * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  69      * JDK 1.4 serialVersionUID
  70      */
  71     private static final long serialVersionUID = 486933713763926351L;
  72 
  73     private boolean implicitDownCycleTraversal = true;
  74 
  75     /**
  76      * Used by getComponentAfter and getComponentBefore for efficiency. In
  77      * order to maintain compliance with the specification of
  78      * FocusTraversalPolicy, if traversal wraps, we should invoke
  79      * getFirstComponent or getLastComponent. These methods may be overriden in
  80      * subclasses to behave in a non-generic way. However, in the generic case,
  81      * these methods will simply return the first or last Components of the
  82      * sorted list, respectively. Since getComponentAfter and
  83      * getComponentBefore have already built the list before determining
  84      * that they need to invoke getFirstComponent or getLastComponent, the
  85      * list should be reused if possible.
  86      */
  87     private transient Container cachedRoot;
  88     private transient List<Component> cachedCycle;





  89 
  90     /*
  91      * We suppose to use getFocusTraversalCycle & getComponentIndex methods in order
  92      * to divide the policy into two parts:
  93      * 1) Making the focus traversal cycle.
  94      * 2) Traversing the cycle.
  95      * The 1st point assumes producing a list of components representing the focus
  96      * traversal cycle. The two methods mentioned above should implement this logic.
  97      * The 2nd point assumes implementing the common concepts of operating on the
  98      * cycle: traversing back and forth, retrieving the initial/default/first/last
  99      * component. These concepts are described in the AWT Focus Spec and they are
 100      * applied to the FocusTraversalPolicy in general.
 101      * Thus, a descendant of this policy may wish to not reimplement the logic of
 102      * the 2nd point but just override the implementation of the 1st one.
 103      * A striking example of such a descendant is the javax.swing.SortingFocusTraversalPolicy.
 104      */
 105     /*protected*/ private List<Component> getFocusTraversalCycle(Container aContainer) {
 106         List<Component> cycle = new ArrayList<Component>();
 107         enumerateCycle(aContainer, cycle);
 108         return cycle;


   1 /*
   2  * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  69      * JDK 1.4 serialVersionUID
  70      */
  71     private static final long serialVersionUID = 486933713763926351L;
  72 
  73     private boolean implicitDownCycleTraversal = true;
  74 
  75     /**
  76      * Used by getComponentAfter and getComponentBefore for efficiency. In
  77      * order to maintain compliance with the specification of
  78      * FocusTraversalPolicy, if traversal wraps, we should invoke
  79      * getFirstComponent or getLastComponent. These methods may be overriden in
  80      * subclasses to behave in a non-generic way. However, in the generic case,
  81      * these methods will simply return the first or last Components of the
  82      * sorted list, respectively. Since getComponentAfter and
  83      * getComponentBefore have already built the list before determining
  84      * that they need to invoke getFirstComponent or getLastComponent, the
  85      * list should be reused if possible.
  86      */
  87     private transient Container cachedRoot;
  88     private transient List<Component> cachedCycle;
  89 
  90     /**
  91      * Constructs a {@code ContainerOrderFocusTraversalPolicy}.
  92      */
  93     public ContainerOrderFocusTraversalPolicy() {}
  94 
  95     /*
  96      * We suppose to use getFocusTraversalCycle & getComponentIndex methods in order
  97      * to divide the policy into two parts:
  98      * 1) Making the focus traversal cycle.
  99      * 2) Traversing the cycle.
 100      * The 1st point assumes producing a list of components representing the focus
 101      * traversal cycle. The two methods mentioned above should implement this logic.
 102      * The 2nd point assumes implementing the common concepts of operating on the
 103      * cycle: traversing back and forth, retrieving the initial/default/first/last
 104      * component. These concepts are described in the AWT Focus Spec and they are
 105      * applied to the FocusTraversalPolicy in general.
 106      * Thus, a descendant of this policy may wish to not reimplement the logic of
 107      * the 2nd point but just override the implementation of the 1st one.
 108      * A striking example of such a descendant is the javax.swing.SortingFocusTraversalPolicy.
 109      */
 110     /*protected*/ private List<Component> getFocusTraversalCycle(Container aContainer) {
 111         List<Component> cycle = new ArrayList<Component>();
 112         enumerateCycle(aContainer, cycle);
 113         return cycle;


< prev index next >