Component focus

Working on an input form where the user is setting up a recipe to be stored in a database.
Each field is validated when leaving the text field and works great. However on the form there’s an ‘Accept’ button, which for visuals is disabled while the form is incorrect (all fields is validated on accept).
All navigation in the form is set up to work as expected with tab, the only issue I can’t seem to find a solution to is how to not skip the accept button when tabbing from the last input field. If the form is valid and the button is enabled when tabbing from the last field the button gains focus.

Anyone who can come up with a clever idea for this? Have been messing with this for some time now and can’t seem to find a ‘simple’ clean solution for something soooo simple :slight_smile:

Leave it enabled. Fake the visuals so it looks disabled, and check the faked status in the actionPerformed event to make sure it won’t react when the form isn’t valid.

Hello Phil,

Found a simple way. Simply doing this on the last text field in the property changed event seems to fix a day of failed attempts.

1 Like