7894 boolean transferFocusBackward(boolean clearOnFailure) {
7895 Container rootAncestor = getTraversalRoot();
7896 Component comp = this;
7897 while (rootAncestor != null &&
7898 !(rootAncestor.isShowing() && rootAncestor.canBeFocusOwner()))
7899 {
7900 comp = rootAncestor;
7901 rootAncestor = comp.getFocusCycleRootAncestor();
7902 }
7903 boolean res = false;
7904 if (rootAncestor != null) {
7905 FocusTraversalPolicy policy = rootAncestor.getFocusTraversalPolicy();
7906 Component toFocus = policy.getComponentBefore(rootAncestor, comp);
7907 if (toFocus == null) {
7908 toFocus = policy.getDefaultComponent(rootAncestor);
7909 }
7910 if (toFocus != null) {
7911 res = toFocus.requestFocusInWindow(CausedFocusEvent.Cause.TRAVERSAL_BACKWARD);
7912 }
7913 }
7914 if (!res) {
7915 if (focusLog.isLoggable(PlatformLogger.FINER)) {
7916 focusLog.finer("clear global focus owner");
7917 }
7918 KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
7919 }
7920 if (focusLog.isLoggable(PlatformLogger.FINER)) {
7921 focusLog.finer("returning result: " + res);
7922 }
7923 return res;
7924 }
7925
7926 /**
7927 * Transfers the focus up one focus traversal cycle. Typically, the focus
7928 * owner is set to this Component's focus cycle root, and the current focus
7929 * cycle root is set to the new focus owner's focus cycle root. If,
7930 * however, this Component's focus cycle root is a Window, then the focus
7931 * owner is set to the focus cycle root's default Component to focus, and
7932 * the current focus cycle root is unchanged.
7933 *
7934 * @see #requestFocus()
|
7894 boolean transferFocusBackward(boolean clearOnFailure) {
7895 Container rootAncestor = getTraversalRoot();
7896 Component comp = this;
7897 while (rootAncestor != null &&
7898 !(rootAncestor.isShowing() && rootAncestor.canBeFocusOwner()))
7899 {
7900 comp = rootAncestor;
7901 rootAncestor = comp.getFocusCycleRootAncestor();
7902 }
7903 boolean res = false;
7904 if (rootAncestor != null) {
7905 FocusTraversalPolicy policy = rootAncestor.getFocusTraversalPolicy();
7906 Component toFocus = policy.getComponentBefore(rootAncestor, comp);
7907 if (toFocus == null) {
7908 toFocus = policy.getDefaultComponent(rootAncestor);
7909 }
7910 if (toFocus != null) {
7911 res = toFocus.requestFocusInWindow(CausedFocusEvent.Cause.TRAVERSAL_BACKWARD);
7912 }
7913 }
7914 if (clearOnFailure && !res) {
7915 if (focusLog.isLoggable(PlatformLogger.FINER)) {
7916 focusLog.finer("clear global focus owner");
7917 }
7918 KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
7919 }
7920 if (focusLog.isLoggable(PlatformLogger.FINER)) {
7921 focusLog.finer("returning result: " + res);
7922 }
7923 return res;
7924 }
7925
7926 /**
7927 * Transfers the focus up one focus traversal cycle. Typically, the focus
7928 * owner is set to this Component's focus cycle root, and the current focus
7929 * cycle root is set to the new focus owner's focus cycle root. If,
7930 * however, this Component's focus cycle root is a Window, then the focus
7931 * owner is set to the focus cycle root's default Component to focus, and
7932 * the current focus cycle root is unchanged.
7933 *
7934 * @see #requestFocus()
|