bibliothek.gui.dock.focus
Class DockFocusTraversalPolicy

java.lang.Object
  extended by java.awt.FocusTraversalPolicy
      extended by bibliothek.gui.dock.focus.DockFocusTraversalPolicy

public class DockFocusTraversalPolicy
extends java.awt.FocusTraversalPolicy

A FocusTraversalPolicy that uses the algorithms of a SimplifiedFocusTraversalPolicy to do its work. This policy ensures that only valid Components are selected, and it respects the constraints for nested policies.

Author:
Benjamin Sigg

Constructor Summary
DockFocusTraversalPolicy(SimplifiedFocusTraversalPolicy policy, boolean circle)
          Creates a new policy.
 
Method Summary
protected  boolean accept(java.awt.Component component)
          Tells whether component can be focused or not.
protected  java.awt.Component after(java.awt.Component component)
          Searches the next Component which might gain the focus.
protected  java.awt.Component before(java.awt.Component component)
          Searches the previous Component which might gain the focus.
 java.awt.Component getComponentAfter(java.awt.Container container, java.awt.Component component)
           
 java.awt.Component getComponentBefore(java.awt.Container container, java.awt.Component component)
           
 java.awt.Component getDefaultComponent(java.awt.Container container)
           
 java.awt.Component getFirstComponent(java.awt.Container container)
           
protected  java.awt.FocusTraversalPolicy getFocusTraversalPolicy(java.awt.Container provider)
          Searches the FocusTraversalPolicy which should be used by provider.
 java.awt.Component getLastComponent(java.awt.Container container)
           
protected  java.awt.Container getRootOrProvider(java.awt.Component component)
          Searches the first parent of component that is either a focus cycle root or a policy provider.
 
Methods inherited from class java.awt.FocusTraversalPolicy
getInitialComponent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DockFocusTraversalPolicy

public DockFocusTraversalPolicy(SimplifiedFocusTraversalPolicy policy,
                                boolean circle)
Creates a new policy.

Parameters:
policy - the delegate providing algorithms for this policy
circle - if true then this policy does not respect the exact description of the functionality of FocusTraversalPolicy in order to ensure that getComponentAfter( getComponentBefore( x )) == x and getComponentBefore( getComponentAfter( x )) == x.
Method Detail

accept

protected boolean accept(java.awt.Component component)
Tells whether component can be focused or not.

Parameters:
component - some Component which might gain the focus.
Returns:
true if component is allowed to gain the focus, false otherwise

getComponentAfter

public java.awt.Component getComponentAfter(java.awt.Container container,
                                            java.awt.Component component)
Specified by:
getComponentAfter in class java.awt.FocusTraversalPolicy

after

protected java.awt.Component after(java.awt.Component component)
Searches the next Component which might gain the focus. This method searches recursively through the tree of Components, but does not loop.

Parameters:
component - the currently focused Component.
Returns:
the next Component which might gain the focus

getComponentBefore

public java.awt.Component getComponentBefore(java.awt.Container container,
                                             java.awt.Component component)
Specified by:
getComponentBefore in class java.awt.FocusTraversalPolicy

before

protected java.awt.Component before(java.awt.Component component)
Searches the previous Component which might gain the focus. This method searches recursively through the tree of Components, but does not loop.

Parameters:
component - the currently focused Component.
Returns:
the previous Component which might gain the focus

getDefaultComponent

public java.awt.Component getDefaultComponent(java.awt.Container container)
Specified by:
getDefaultComponent in class java.awt.FocusTraversalPolicy

getFirstComponent

public java.awt.Component getFirstComponent(java.awt.Container container)
Specified by:
getFirstComponent in class java.awt.FocusTraversalPolicy

getLastComponent

public java.awt.Component getLastComponent(java.awt.Container container)
Specified by:
getLastComponent in class java.awt.FocusTraversalPolicy

getRootOrProvider

protected java.awt.Container getRootOrProvider(java.awt.Component component)
Searches the first parent of component that is either a focus cycle root or a policy provider.

Parameters:
component - some component
Returns:
some parent or null

getFocusTraversalPolicy

protected java.awt.FocusTraversalPolicy getFocusTraversalPolicy(java.awt.Container provider)
Searches the FocusTraversalPolicy which should be used by provider. This method searches for a focus cycle root or policy provider whose traversal policy is set.

Parameters:
provider - a focus cycle root or policy provider whose SimplifiedFocusTraversalPolicy is searched.
Returns:
the policy of provider or null