• Post Reply Bookmark Topic Watch Topic
  • New Topic

Prevent focus change for JButtons

 
Toa van Steen
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I've written a little piece of code that takes a list of JButtons (each constructed using the JButton(Action a) constructor) and arranges them on a JPanel (in an extremely beautiful manner, of course ).

My little problem is this: after the user clicked on button i (and the respective action was performed) button i+1 receives the focus. In other words: Although I do want the user to be able to move the focus using the TAB key, I do not want the focus to change when a button is pressed/clicked.

Does anyone know an elegant way to achieve this? Thanks!
[ January 07, 2008: Message edited by: Toa van Steen ]
 
Brian Cole
Author
Ranch Hand
Posts: 920
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Toa van Steen:
My little problem is this: after the user clicked on button i (and the respective action was performed) button i+1 receives the focus. In other words: Although I do want the user to be able to move the focus using the TAB key, I do not want the focus to change when a button is pressed/clicked.


I've never heard of such a thing. In most LnFs the focus stays with the button after it is pressed.

What are the ActionListeners doing? Have you written any focus code?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!