Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Enable Custom FocusTraversalPolicy In Swing

DZone's Guide to

Enable Custom FocusTraversalPolicy In Swing

·
Free Resource
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);
Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}