DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Enable Custom FocusTraversalPolicy In Swing

10.12.2006
| 7675 views |
  • submit to reddit
        Every container in Swing/AWT can be given a FocusTraversalPolicy with:
public void setFocusTraversalPolicy(FocusTraversalPolicy policy)
Remember to enable the container as a FocusCycleRoot:
setFocusCycleRoot(true)
Together it looks like:
container.setFocusTraversalPolicy(myCustomPolicy);
container.setFocusCycleRoot(true);