e615. Finding the Next Focusable Component

Posted borter

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了e615. Finding the Next Focusable Component相关的知识,希望对你有一定的参考价值。

public Component findNextFocus() {
        // Find focus owner
        Component c = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
        Container root = c == null ? null : c.getFocusCycleRootAncestor();
    
        if (root != null) {
            FocusTraversalPolicy policy = root.getFocusTraversalPolicy();
            Component nextFocus = policy.getComponentAfter(root, c);
            if (nextFocus == null) {
                nextFocus = policy.getDefaultComponent(root);
            }
            return nextFocus;
        }
        return null;
    }
    
    public Component findPrevFocus() {
        // Find focus owner
        Component c = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
        Container root = c == null ? null : c.getFocusCycleRootAncestor();
    
        if (root != null) {
            FocusTraversalPolicy policy = root.getFocusTraversalPolicy();
            Component prevFocus = policy.getComponentBefore(root, c);
            if (prevFocus == null) {
                prevFocus = policy.getDefaultComponent(root);
            }
            return prevFocus;
        }
        return null;
    }

 

Related Examples

以上是关于e615. Finding the Next Focusable Component的主要内容,如果未能解决你的问题,请参考以下文章

FINDING THE FACTS

Finding Lane Lines on the Road

代写Java小程序: Finding customer clusters at the Telco

ICPC2017 Hua-Lian Finding the Bases(字符串,kmp)

e612. Moving the Focus to the Next or Previous Focusable Component

CodeForces615B-Longtail Hedgehog-dp/图