Overview
Package
Class
Use
Tree
Deprecated
Index
All Classes
Help
Prev Class
Next Class
Sample
Document
Class java.awt.DefaultFocusTraversalPolicy
Inherited members: ShowHide
Deprecated: ShowHide
View: ClientSubclassPackageImplementation
java.awt

Class DefaultFocusTraversalPolicy

  • java.lang.Object
    • java.awt.FocusTraversalPolicy
      • java.awt.ContainerOrderFocusTraversalPolicy
        • java.awt.DefaultFocusTraversalPolicy
  • All Implemented Interfaces:
    java.io.Serializable
    public class DefaultFocusTraversalPolicy extends ContainerOrderFocusTraversalPolicy
    A FocusTraversalPolicy that determines traversal order based on the order of child Components in a Container. From a particular focus cycle root, the policy makes a pre-order traversal of the Component hierarchy, and traverses a Container's children according to the ordering of the array returned by Container.getComponents(). Portions of the hierarchy that are not visible and displayable will not be searched.

    If client code has explicitly set the focusability of a Component by either overriding Component.isFocusTraversable() or Component.isFocusable(), or by calling Component.setFocusable(), then a DefaultFocusTraversalPolicy behaves exactly like a ContainerOrderFocusTraversalPolicy. If, however, the Component is relying on default focusability, then a DefaultFocusTraversalPolicy will reject all Components with non-focusable peers. This is the default FocusTraversalPolicy for all AWT Containers.

    The focusability of a peer is implementation-dependent. Sun recommends that all implementations for a particular native platform construct peers with the same focusability. The recommendations for Windows and Unix are that Canvases, Labels, Panels, Scrollbars, ScrollPanes, Windows, and lightweight Components have non-focusable peers, and all other Components have focusable peers. These recommendations are used in the Sun AWT implementations. Note that the focusability of a Component's peer is different from, and does not impact, the focusability of the Component itself.

    Please see How to Use the Focus Subsystem, a section in The Java Tutorial, and the Focus Specification for more information.

    Since:
    1.4
    See Also:
    Container.getComponents(), Component.isFocusable(), Component.setFocusable(boolean), Serialized Form
    • Constructors 
      Constructor and Description
      Ordinary member indicator DefaultFocusTraversalPolicy Reveal DetailHide Detail
      DefaultFocusTraversalPolicy()
       
      public DefaultFocusTraversalPolicy()
    • Methods 
      Modifier and Type Method and Description
      Overridden member indicator accept Reveal DetailHide Detail
      protected boolean accept(Component aComponent)
      Determines whether a Component is an acceptable choice as the new focus owner.
      protected boolean accept(Component aComponent)
      Determines whether a Component is an acceptable choice as the new focus owner. The Component must be visible, displayable, and enabled to be accepted. If client code has explicitly set the focusability of the Component by either overriding Component.isFocusTraversable() or Component.isFocusable(), or by calling Component.setFocusable(), then the Component will be accepted if and only if it is focusable. If, however, the Component is relying on default focusability, then all Canvases, Labels, Panels, Scrollbars, ScrollPanes, Windows, and lightweight Components will be rejected.
      Overrides:
      accept in class ContainerOrderFocusTraversalPolicy
      Parameters:
      aComponent - the Component whose fitness as a focus owner is to be tested
      Returns:
      true if aComponent meets the above requirements; false otherwise
      Inherited member indicator getComponentAfter Reveal DetailHide Detail
      Component getComponentAfter(Container aContainer, Component aComponent)
      Returns the Component that should receive the focus after aComponent.
      public Component getComponentAfter(Container aContainer, Component aComponent)
      Description copied from class: ContainerOrderFocusTraversalPolicy
      Returns the Component that should receive the focus after aComponent. aContainer must be a focus cycle root of aComponent or a focus traversal policy provider.

      By default, ContainerOrderFocusTraversalPolicy implicitly transfers focus down-cycle. That is, during normal forward focus traversal, the Component traversed after a focus cycle root will be the focus-cycle- root's default Component to focus. This behavior can be disabled using the setImplicitDownCycleTraversal method.

      If aContainer is focus traversal policy provider, the focus is always transferred down-cycle.

      Specified by:
      getComponentAfter in class FocusTraversalPolicy
      Parameters:
      aContainer - a focus cycle root of aComponent or a focus traversal policy provider
      aComponent - a (possibly indirect) child of aContainer, or aContainer itself
      Returns:
      the Component that should receive the focus after aComponent, or null if no suitable Component can be found
      Throws:
      java.lang.IllegalArgumentException - if aContainer is not a focus cycle root of aComponent or focus traversal policy provider, or if either aContainer or aComponent is null
      Inherited member indicator getComponentBefore Reveal DetailHide Detail
      Component getComponentBefore(Container aContainer, Component aComponent)
      Returns the Component that should receive the focus before aComponent.
      public Component getComponentBefore(Container aContainer, Component aComponent)
      Description copied from class: ContainerOrderFocusTraversalPolicy
      Returns the Component that should receive the focus before aComponent. aContainer must be a focus cycle root of aComponent or a focus traversal policy provider.
      Specified by:
      getComponentBefore in class FocusTraversalPolicy
      Parameters:
      aContainer - a focus cycle root of aComponent or focus traversal policy provider
      aComponent - a (possibly indirect) child of aContainer, or aContainer itself
      Returns:
      the Component that should receive the focus before aComponent, or null if no suitable Component can be found
      Throws:
      java.lang.IllegalArgumentException - if aContainer is not a focus cycle root of aComponent or focus traversal policy provider, or if either aContainer or aComponent is null
      Inherited member indicator getDefaultComponent Reveal DetailHide Detail
      Component getDefaultComponent(Container aContainer)
      Returns the default Component to focus.
      public Component getDefaultComponent(Container aContainer)
      Description copied from class: ContainerOrderFocusTraversalPolicy
      Returns the default Component to focus. This Component will be the first to receive focus when traversing down into a new focus traversal cycle rooted at aContainer. The default implementation of this method returns the same Component as getFirstComponent.
      Specified by:
      getDefaultComponent in class FocusTraversalPolicy
      Parameters:
      aContainer - the focus cycle root or focus traversal policy provider whose default Component is to be returned
      Returns:
      the default Component in the traversal cycle of aContainer, or null if no suitable Component can be found
      Throws:
      java.lang.IllegalArgumentException - if aContainer is null
      See Also:
      ContainerOrderFocusTraversalPolicy.getFirstComponent(java.awt.Container)
      Inherited member indicator getFirstComponent Reveal DetailHide Detail
      Component getFirstComponent(Container aContainer)
      Returns the first Component in the traversal cycle.
      public Component getFirstComponent(Container aContainer)
      Description copied from class: ContainerOrderFocusTraversalPolicy
      Returns the first Component in the traversal cycle. This method is used to determine the next Component to focus when traversal wraps in the forward direction.
      Specified by:
      getFirstComponent in class FocusTraversalPolicy
      Parameters:
      aContainer - the focus cycle root or focus traversal policy provider whose first Component is to be returned
      Returns:
      the first Component in the traversal cycle of aContainer, or null if no suitable Component can be found
      Throws:
      java.lang.IllegalArgumentException - if aContainer is null
      Inherited member indicator getImplicitDownCycleTraversal Reveal DetailHide Detail
      boolean getImplicitDownCycleTraversal()
      Returns whether this ContainerOrderFocusTraversalPolicy transfers focus down-cycle implicitly.
      public boolean getImplicitDownCycleTraversal()
      Description copied from class: ContainerOrderFocusTraversalPolicy
      Returns whether this ContainerOrderFocusTraversalPolicy transfers focus down-cycle implicitly. If true, during normal forward focus traversal, the Component traversed after a focus cycle root will be the focus-cycle-root's default Component to focus. If false, the next Component in the focus traversal cycle rooted at the specified focus cycle root will be traversed instead.
      Returns:
      whether this ContainerOrderFocusTraversalPolicy transfers focus down-cycle implicitly
      See Also:
      ContainerOrderFocusTraversalPolicy.setImplicitDownCycleTraversal(boolean), ContainerOrderFocusTraversalPolicy.getFirstComponent(java.awt.Container)
      Inherited member indicator getInitialComponent Reveal DetailHide Detail
      Component getInitialComponent(Window window)
      Returns the Component that should receive the focus when a Window is made visible for the first time.
      public Component getInitialComponent(Window window)
      Description copied from class: FocusTraversalPolicy
      Returns the Component that should receive the focus when a Window is made visible for the first time. Once the Window has been made visible by a call to show() or setVisible(true), the initial Component will not be used again. Instead, if the Window loses and subsequently regains focus, or is made invisible or undisplayable and subsequently made visible and displayable, the Window's most recently focused Component will become the focus owner. The default implementation of this method returns the default Component.
      Parameters:
      window - the Window whose initial Component is to be returned
      Returns:
      the Component that should receive the focus when window is made visible for the first time, or null if no suitable Component can be found
      Throws:
      java.lang.IllegalArgumentException - if window is null
      See Also:
      FocusTraversalPolicy.getDefaultComponent(java.awt.Container), Window.getMostRecentFocusOwner()
      Inherited member indicator getLastComponent Reveal DetailHide Detail
      Component getLastComponent(Container aContainer)
      Returns the last Component in the traversal cycle.
      public Component getLastComponent(Container aContainer)
      Description copied from class: ContainerOrderFocusTraversalPolicy
      Returns the last Component in the traversal cycle. This method is used to determine the next Component to focus when traversal wraps in the reverse direction.
      Specified by:
      getLastComponent in class FocusTraversalPolicy
      Parameters:
      aContainer - the focus cycle root or focus traversal policy provider whose last Component is to be returned
      Returns:
      the last Component in the traversal cycle of aContainer, or null if no suitable Component can be found
      Throws:
      java.lang.IllegalArgumentException - if aContainer is null
      Inherited member indicator setImplicitDownCycleTraversal Reveal DetailHide Detail
      void setImplicitDownCycleTraversal(boolean implicitDownCycleTraversal)
      Sets whether this ContainerOrderFocusTraversalPolicy transfers focus down-cycle implicitly.
      public void setImplicitDownCycleTraversal(boolean implicitDownCycleTraversal)
      Description copied from class: ContainerOrderFocusTraversalPolicy
      Sets whether this ContainerOrderFocusTraversalPolicy transfers focus down-cycle implicitly. If true, during normal forward focus traversal, the Component traversed after a focus cycle root will be the focus-cycle-root's default Component to focus. If false, the next Component in the focus traversal cycle rooted at the specified focus cycle root will be traversed instead. The default value for this property is true.
      Parameters:
      implicitDownCycleTraversal - whether this ContainerOrderFocusTraversalPolicy transfers focus down-cycle implicitly
      See Also:
      ContainerOrderFocusTraversalPolicy.getImplicitDownCycleTraversal(), ContainerOrderFocusTraversalPolicy.getFirstComponent(java.awt.Container)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
This document was created by Dulcet from the OpenJDK sources. Copyright © 1993, 2012 Oracle and/or its affiliates. All rights reserved.

SourceForge