n8.
n8.

Reputation: 1738

Java tab order: setFocusTraversalPolicy

My tab order is not doing what I intuitively would suppose it should. Here is my setFocusTraversalPolicy:

import org.eclipse.wb.swing.FocusTraversalOnArray;

...

p_1.setFocusTraversalPolicy(new FocusTraversalOnArray(new Component[]{
    cmbFnName, cmbFn, txtXoffset, txtYoffset, txtDomStart, txtDomEnd}));

When tabbing through, the textbox txtYoffset is moved to the end of the tab order. The controls are also initialized in the order specified in the Traversal Policy. What could be the overriding logic that is to blame for what I see in this behavior? I'm using Eclipse Mars.

Upvotes: 0

Views: 1232

Answers (1)

Dakshinamurthy Karra
Dakshinamurthy Karra

Reputation: 5463

The focus traversal policy of a container is used only when it is the focus cycle root. Else it's parent's focus traversal policy is used. Try setting p_1 as the focus cycle root by calling p_1.setFocusCycleRoot(true) in your initialisation routine.

Upvotes: 2

Related Questions