user496789
user496789

Reputation: 107

Short cut keys in java

How can I write programs for shortcut keys in java. For Example, ctrl+s means the save option should work. Can anyone help?

Upvotes: 0

Views: 678

Answers (4)

gerardw
gerardw

Reputation: 6330

If you're developing on Mac OS X, use accelerators instead of mnenomics, which are not suppported under the native look and feel Apple Java development guide

Upvotes: 0

camickr
camickr

Reputation: 324098

Swing was designed to use Key Bindings for this type of functionality. You create an Action and map a KeyStroke to invoke this Action. Read the section from the Swing tutorial on How to Write an Action for more information.

Upvotes: 0

Vladimir
Vladimir

Reputation: 10493

Basically you're need to set mnemonics for appropriate buttons. Also you can set some accelerators for menu items. Here is a rather good example.

Upvotes: 3

initialZero
initialZero

Reputation: 6367

You want to read the Java tutorial for Key Listeners

Upvotes: 2

Related Questions