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

Print this page




 487                 cycle = getFocusTraversalCycle(aContainer);
 488             }
 489 
 490             if (cycle.size() == 0) {
 491                 if (log.isLoggable(PlatformLogger.Level.FINE)) {
 492                     log.fine("### Cycle is empty");
 493                 }
 494                 return null;
 495             }
 496             if (log.isLoggable(PlatformLogger.Level.FINE)) {
 497                 log.fine("### Cycle is " + cycle);
 498             }
 499 
 500             for (int i= cycle.size() - 1; i >= 0; i--) {
 501                 Component comp = cycle.get(i);
 502                 if (accept(comp)) {
 503                     return comp;
 504                 } else if (comp instanceof Container && comp != aContainer) {
 505                     Container cont = (Container)comp;
 506                     if (cont.isFocusTraversalPolicyProvider()) {
 507                         return cont.getFocusTraversalPolicy().getLastComponent(cont);



 508                     }
 509                 }
 510             }
 511         }
 512         return null;
 513     }
 514 
 515     /**
 516      * Returns the default Component to focus. This Component will be the first
 517      * to receive focus when traversing down into a new focus traversal cycle
 518      * rooted at aContainer. The default implementation of this method
 519      * returns the same Component as <code>getFirstComponent</code>.
 520      *
 521      * @param aContainer the focus cycle root or focus traversal policy provider whose default
 522      *        Component is to be returned
 523      * @return the default Component in the traversal cycle of aContainer,
 524      *         or null if no suitable Component can be found
 525      * @see #getFirstComponent
 526      * @throws IllegalArgumentException if aContainer is null
 527      */




 487                 cycle = getFocusTraversalCycle(aContainer);
 488             }
 489 
 490             if (cycle.size() == 0) {
 491                 if (log.isLoggable(PlatformLogger.Level.FINE)) {
 492                     log.fine("### Cycle is empty");
 493                 }
 494                 return null;
 495             }
 496             if (log.isLoggable(PlatformLogger.Level.FINE)) {
 497                 log.fine("### Cycle is " + cycle);
 498             }
 499 
 500             for (int i= cycle.size() - 1; i >= 0; i--) {
 501                 Component comp = cycle.get(i);
 502                 if (accept(comp)) {
 503                     return comp;
 504                 } else if (comp instanceof Container && comp != aContainer) {
 505                     Container cont = (Container)comp;
 506                     if (cont.isFocusTraversalPolicyProvider()) {
 507                         Component retComp = cont.getFocusTraversalPolicy().getLastComponent(cont);
 508                         if (retComp != null) {
 509                             return retComp;
 510                         }
 511                     }
 512                 }
 513             }
 514         }
 515         return null;
 516     }
 517 
 518     /**
 519      * Returns the default Component to focus. This Component will be the first
 520      * to receive focus when traversing down into a new focus traversal cycle
 521      * rooted at aContainer. The default implementation of this method
 522      * returns the same Component as <code>getFirstComponent</code>.
 523      *
 524      * @param aContainer the focus cycle root or focus traversal policy provider whose default
 525      *        Component is to be returned
 526      * @return the default Component in the traversal cycle of aContainer,
 527      *         or null if no suitable Component can be found
 528      * @see #getFirstComponent
 529      * @throws IllegalArgumentException if aContainer is null
 530      */