- All Implemented Interfaces:
Serializable
ComponentOrientation
for more information. All columns in a
row are fully traversed before proceeding to the next row.- Since:
- 1.4
- See Also:
ComponentOrientation
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
Determines whether the specifiedComponent
is an acceptable choice as the new focus owner.getComponentAfter(Container aContainer, Component aComponent)
Returns the Component that should receive the focus after aComponent.getComponentBefore(Container aContainer, Component aComponent)
Returns the Component that should receive the focus before aComponent.getFirstComponent(Container aContainer)
Returns the first Component in the traversal cycle.getLastComponent(Container aContainer)
Returns the last Component in the traversal cycle.Methods declared in class javax.swing.SortingFocusTraversalPolicy
getComparator, getDefaultComponent, getImplicitDownCycleTraversal, setComparator, setImplicitDownCycleTraversal
Methods declared in class javax.swing.InternalFrameFocusTraversalPolicy
getInitialComponent
Methods declared in class java.awt.FocusTraversalPolicy
getInitialComponent
-
Constructor Details
-
LayoutFocusTraversalPolicy
public LayoutFocusTraversalPolicy()Constructs a LayoutFocusTraversalPolicy.
-
-
Method Details
-
getComponentAfter
Returns the Component that should receive the focus after aComponent. aContainer must be a focus cycle root of aComponent.By default, LayoutFocusTraversalPolicy implicitly transfers focus down- cycle. That is, during normal 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.
- Overrides:
getComponentAfter
in classSortingFocusTraversalPolicy
- Parameters:
aContainer
- a focus cycle root of aComponent or a focus traversal policy provideraComponent
- 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:
IllegalArgumentException
- if aContainer is not a focus cycle root of aComponent or a focus traversal policy provider, or if either aContainer or aComponent is null
-
getComponentBefore
Returns the Component that should receive the focus before aComponent. aContainer must be a focus cycle root of aComponent.By default, LayoutFocusTraversalPolicy implicitly transfers focus down- cycle. That is, during normal 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.
- Overrides:
getComponentBefore
in classSortingFocusTraversalPolicy
- Parameters:
aContainer
- a focus cycle root of aComponent or a focus traversal policy provideraComponent
- 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:
IllegalArgumentException
- if aContainer is not a focus cycle root of aComponent or a focus traversal policy provider, or if either aContainer or aComponent is null
-
getFirstComponent
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.- Overrides:
getFirstComponent
in classSortingFocusTraversalPolicy
- Parameters:
aContainer
- a focus cycle root of aComponent or a 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:
IllegalArgumentException
- if aContainer is null
-
getLastComponent
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.- Overrides:
getLastComponent
in classSortingFocusTraversalPolicy
- Parameters:
aContainer
- a focus cycle root of aComponent or a 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:
IllegalArgumentException
- if aContainer is null
-
accept
Determines whether the specifiedComponent
is an acceptable choice as the new focus owner. This method performs the following sequence of operations:- Checks whether
aComponent
is visible, displayable, enabled, and focusable. If any of these properties isfalse
, this method returnsfalse
. - If
aComponent
is an instance ofJTable
, returnstrue
. - If
aComponent
is an instance ofJComboBox
, then returns the value ofaComponent.getUI().isFocusTraversable(aComponent)
. - If
aComponent
is aJComponent
with aJComponent.WHEN_FOCUSED
InputMap
that is neithernull
nor empty, returnstrue
. - Returns the value of
DefaultFocusTraversalPolicy.accept(aComponent)
.
- Overrides:
accept
in classSortingFocusTraversalPolicy
- Parameters:
aComponent
- theComponent
whose fitness as a focus owner is to be tested- Returns:
true
ifaComponent
is a valid choice for a focus owner; otherwisefalse
- See Also:
Component.isVisible()
,Component.isDisplayable()
,Component.isEnabled()
,Component.isFocusable()
,ComboBoxUI.isFocusTraversable(javax.swing.JComboBox<?>)
,JComponent.getInputMap(int)
,DefaultFocusTraversalPolicy.accept(java.awt.Component)
- Checks whether
-