FocusTraversalPolicy not working

I have a gui with some JTextfiles. Most of the are disabled, but some are editable. At the bottom are 3 buttons which of one is diabled (either number 1 or number 2). Now I was asked to set focus on the third button (Cancel) just to avoid people my accident delete the data in the JTextfiles. I added a FocusTraversalPolicy. I have used it before in other projects. I put the 3 buttons in the list to avoid messing with the fields, but I do not get any effect at all. The same JTextfiled has the initial focus. What can I do? DOes the Layout manager have any effect?
This is the call I do? Where do I need to call it?

Open in new window

Who is Participating?
ksivananthConnect With a Mentor Commented:
or you may try with requestFocusInWindow, check this example
mdolandAuthor Commented:
As it seems now, the problem comes from that the GUI doesn't contain a layout manager. It is initiated with null. What is the best way to at least avoid that one of the fields will be the deafult component?
can you post the policy implementation?
mdolandAuthor Commented:
None of this seems to work. I think it has to do with that no layout manager is used.It looks like this:


It put focus on the top component what ever I do.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.