Java Swing FocusTraversalPolicy

I am using FocusTraversalPolicy policy in my Swing Project for tab out functionality. In some screens some componenets(combo box , textbox etc) are disabled in between some enabled components. So when i tab out from those which are enabled it loses focus when i tab out as that component after was disabled in that screen. So i started using if else loops to check which is the next enabled component in that order and set focus on it.

Is there a way in Swing builtin to tab out to the next focusable component in that order specified or should i manually do it for each component( if else checks). This code should apply to both Component after and component before functionality.

Regards,
Hemanth
( http://www.freejavaguide.com }

Comments

  • : I am using FocusTraversalPolicy policy in my Swing Project for tab out functionality. In some screens some componenets(combo box , textbox etc) are disabled in between some enabled components. So when i tab out from those which are enabled it loses focus when i tab out as that component after was disabled in that screen. So i started using if else loops to check which is the next enabled component in that order and set focus on it.
    :
    : Is there a way in Swing builtin to tab out to the next focusable component in that order specified or should i manually do it for each component( if else checks). This code should apply to both Component after and component before functionality.
    :
    : Regards,
    : Hemanth
    : ( http://www.freejavaguide.com }
    :
    :
    I would place all the components in an ArrayList and keep track of the current component. That way finding the previous/next component is very simple and enabling/disabling them can be done easily.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion