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 defaultFocusTraversalPolicyfor thisJComponent's focus traversal cycle by unconditionally setting the specifiedComponentas the nextComponentin the cycle, and thisJComponentas the specifiedComponent's previousComponentin 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.
No comments:
Post a Comment