File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes SWT - Mapping key actions (ie Ctrl+S = Save) Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "SWT - Mapping key actions (ie Ctrl+S = Save)" Watch "SWT - Mapping key actions (ie Ctrl+S = Save)" New topic
Author

SWT - Mapping key actions (ie Ctrl+S = Save)

Ivan Jouikov
Ranch Hand

Joined: Jul 22, 2003
Posts: 269
How the hell do you do that? I spent the last two hours searching google with absolutely no result!

shell.addKeyListener( new KeyAdapter ... doesn't work. It works if I add it to a text box, but how would I make a global key listener event?

This is driving me crazy, please help
Nick Kocher
Greenhorn

Joined: Nov 24, 2004
Posts: 14
Privet Ivan!
If you need Ctrl + s for your menuItem in the menu for example, you could use the following code:
menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
Ivan Jouikov
Ranch Hand

Joined: Jul 22, 2003
Posts: 269
Omg that did the trick!

Thanks!
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: SWT - Mapping key actions (ie Ctrl+S = Save)
 
Similar Threads
Key accelerator question
one-to-many relation
Help! Problem using 1:1 CMP Relationship example using JBoss 3.0.0
porting prob in motorola V600
how to detect game action in game loop?