JAVA - How to remove the default action from enter in a Joptionpane?

Asked

Viewed 25 times

2

I have a Joptionpane with the "OK" and "Cancel" options. When navigating with Tab between them, even if Cancel is selected, by pressing Enter it pulls the default option, in case OK, and confirms the operation. Using space it works accordingly and selects, but I need the enter to work the same way as space.

Note: I tried using the

 UIManager.put("Button.defaultButtonFollowsFocus", Boolean.TRUE);

but it didn’t work.

  • Related: https://stackoverflow.com/q/10395181/2241463

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.