JComponent.setNextFocusableComponent() is deprecated since 1.4 ! And yet, this is all Matisse has to offer.
The right way to specify focus cycles since 1.4 is via FocusTraversalPolicy. You just set Container.setFocusCycleRoot(true) and then install your FocusTraversalPolicy subclass.
The problem is that setNextFocusableComponent has priority over the focus policy:
Overrides the default
JComponent's focus traversal cycle by unconditionally setting the specified
Componentas the next
Componentin the cycle, and this
JComponentas the specified
Componentin the cycle. (quote from Javadoc, emphasys mine).
So, if you try to define in Matisse some focus cycle the old fashion way (the only way possible right now) but then you want to use a FocusTraversalPolicy you have to go back and remove all the nextComponents otherwise it will break everything !
My advice: don't use nextFocusable on Matisse ! Do it by hand with FocusTraversalPolicy and wait for the 6.0 release when this should be fixed.
Post a Comment