I want to make a Java swing button 'not-focussable'. The button should not receive focus at all, but should be able to receive mouse clicks.
I thought the following options, but these either dont solve my problem completely, or dont seem elegant. Are there any other/better/suggested options?
- Move the focus to the next component immediately when the button receives focus (but then what do I do if the button is the only component on the UI other than labels?)
- Implement another non-focusable component as a button (a label with mouse events, borders...) (this does not look very elegant to me)
- Create a anonymous button implementation that overides the keyboard events so that it does not respond to keyboard events (this does not solve the focus problem, but is somwhat ok for me, since the root of the problem is to avoid accidental keyboard clicks. I will do this only if there are no options at all, but even then prefer option 2)