1
I need that when I click on some button of my application the focus returns to the JFrame
. Is there any method for this?
I could call the method MeuFrame.requestFocus()
in each ActionPerformed
, but that would take too long.
1
I need that when I click on some button of my application the focus returns to the JFrame
. Is there any method for this?
I could call the method MeuFrame.requestFocus()
in each ActionPerformed
, but that would take too long.
1
There is yes, try:
You tell your jButton
transfer focus and ask for your jFrame
solicit this focus.
jButton.transferFocus();
jFrame.requestFocus();
You can still get focus by forcing through the:
jFrame.grabFocus();
This method gets the focus regardless of who has it (forces the transfer of focus to you), including brings the focus to the window if it is not active.
I would recommend you use the first way, because the effect of the second may be unwanted to the user.
Browser other questions tagged java swing jframe
You are not signed in. Login or sign up in order to post.
there are many buttons on my app... it would take too long...
– Dongabi
there’s no other way?
– Dongabi
each button of yours must say that it must transfer
– Dener
@Dongabi your buttons don’t have an action? Just put at the end of the action.
– Dener