Anto
Anto

Reputation: 4305

Activating a JButton via keyboard

I have a JDialog with two buttons: an OK button and a Cancel button. I would like the Cancel button to be activated by pressing Esc and an OK to be activated by pressing Return. Can someone give me some suggestions for implementing this feature? Thanks!

Upvotes: 3

Views: 1038

Answers (1)

mre
mre

Reputation: 44240

The verb "activate" is ambiguous. But regardless, I suggest you read How to Use Key Bindings.

Upvotes: 4

Related Questions