FocusTraversalPolicy policy = ancestor.getFocusTraversalPolicy();
if (!(policy instanceof SortingFocusTraversalPolicy)) {
return;
}
SortingFocusTraversalPolicy sortingPolicy = (SortingFocusTraversalPolicy)policy;
boolean implicitEnabled = sortingPolicy.getImplicitDownCycleTraversal();
sortingPolicy.setImplicitDownCycleTraversal(false);
Component result = null;
String action = (String)getValue(NAME);
if ("navigateNext".equals(action)) {
result = policy.getComponentAfter(ancestor, desktop);
} else if ("navigatePrevious".equals(action)) {
result = policy.getComponentBefore(ancestor, desktop);
}
sortingPolicy.setImplicitDownCycleTraversal(implicitEnabled);
if (result != null) {
result.requestFocus();
}
}