com.jgoodies.uif.util
Class UIFFocusTraversalPolicy

java.lang.Object
  extended by java.awt.FocusTraversalPolicy
      extended by javax.swing.InternalFrameFocusTraversalPolicy
          extended by javax.swing.SortingFocusTraversalPolicy
              extended by javax.swing.LayoutFocusTraversalPolicy
                  extended by com.jgoodies.uif.util.UIFFocusTraversalPolicy
All Implemented Interfaces:
Serializable

public class UIFFocusTraversalPolicy
extends LayoutFocusTraversalPolicy

A FocusTraversalPolicy that determines traversal order based on the order of child Components in a Container. In addition to its superclass, this class excludes non-editable text components, scroll bars, and the root pane from the focus cycle. Also this policy offers to set an optional initial component that overrides the Swing default initial component.

Since:
1.4
Version:
$Revision: 1.7 $
Author:
Karsten Lentzsch
See Also:
JTextComponent.isEditable(), Serialized Form

Field Summary
static FocusTraversalPolicy DEFAULT
          Holds a default instance of the focus traversal policy, intended to be used as the global default policy.
 
Constructor Summary
UIFFocusTraversalPolicy()
          Constructs a UIFFocusTraversalPolicy with no initial component set.
UIFFocusTraversalPolicy(Component initialComponent)
          Constructs a UIFFocusTraversalPolicy with the given Component as initial component.
 
Method Summary
protected  boolean accept(Component aComponent)
          Determines whether a Component is an acceptable choice as the new focus owner.
 Component getInitialComponent(Window window)
          Returns the Component that should receive the focus when a Window is made visible for the first time.
 void setInitialComponent(Component initialComponent)
          Sets the Component that should receive the focus when a Window is made visible for the first time.
 
Methods inherited from class javax.swing.LayoutFocusTraversalPolicy
getComponentAfter, getComponentBefore, getFirstComponent, getLastComponent
 
Methods inherited from class javax.swing.SortingFocusTraversalPolicy
getComparator, getDefaultComponent, getImplicitDownCycleTraversal, setComparator, setImplicitDownCycleTraversal
 
Methods inherited from class javax.swing.InternalFrameFocusTraversalPolicy
getInitialComponent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT

public static final FocusTraversalPolicy DEFAULT
Holds a default instance of the focus traversal policy, intended to be used as the global default policy.

See Also:
KeyboardFocusManager.setDefaultFocusTraversalPolicy(java.awt.FocusTraversalPolicy)
Constructor Detail

UIFFocusTraversalPolicy

public UIFFocusTraversalPolicy()
Constructs a UIFFocusTraversalPolicy with no initial component set.


UIFFocusTraversalPolicy

public UIFFocusTraversalPolicy(Component initialComponent)
Constructs a UIFFocusTraversalPolicy with the given Component as initial component.

Parameters:
initialComponent - the Component that will be returned as initial component instead of Swing default initial component
Method Detail

accept

protected boolean accept(Component aComponent)
Determines whether a Component is an acceptable choice as the new focus owner. By default, this method will accept a Component if and only if it is visible, displayable, enabled, and focusable, no JScrollBar, no JRootPane, and in case of a JTextComponent, it must be editable.

Overrides:
accept in class LayoutFocusTraversalPolicy
Parameters:
aComponent - the Component whose fitness as a focus owner is to be tested
Returns:
true if aComponent is visible, displayable, enabled, and focusable; false otherwise

setInitialComponent

public void setInitialComponent(Component initialComponent)
Sets the Component that should receive the focus when a Window is made visible for the first time.

Parameters:
initialComponent - the Component that should receive the focus when window is made visible for the first time, or null to use the super implementation's initial component
See Also:
getInitialComponent(Window)

getInitialComponent

public Component getInitialComponent(Window window)
Returns the Component that should receive the focus when a Window is made visible for the first time. In addition to the super implementation this method first checks, if this policy has an initial component set.

Overrides:
getInitialComponent in class FocusTraversalPolicy
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:
IllegalArgumentException - if window is null
See Also:
setInitialComponent(Component), FocusTraversalPolicy.getDefaultComponent(java.awt.Container), Window.getMostRecentFocusOwner()


Copyright © 2000-2008 JGoodies Karsten Lentzsch. All Rights Reserved.