List of usage examples for java.awt FocusTraversalPolicy getComponentBefore
public abstract Component getComponentBefore(Container aContainer, Component aComponent);
From source file:Main.java
public static Component findPrevFocus() { Component c = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); Container root = c.getFocusCycleRootAncestor(); FocusTraversalPolicy policy = root.getFocusTraversalPolicy(); Component prevFocus = policy.getComponentBefore(root, c); if (prevFocus == null) { prevFocus = policy.getDefaultComponent(root); }//from w w w . jav a 2 s.co m return prevFocus; }