The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
September 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Trapping Ctrl + C

Posted by Kishori Sharan on September 15, 2000 at 2:14 PM

Hi
If in a GUI you want to trap Ctrl + C then you need to use registerKeyBoardAction ( ) method of JComponent along with an object of KeyStroke. YOu need to pass an object of a class which implements ActionLisner interface. When that key is pressed actionPerformed ( ActionEvent e ) method will be automatically called and you can do your processing. YOu have also got options when this key press should be trapped e.g. when focus is in that component ot when focus is anywhere or when focus is in the parent of the component. This is useful when you want to trap Ctrl + C in whole window i.e. whenever user presses Ctrl + C you may want to close the window. If you need code let me know I will send you an example.

Thanx
Kishori




Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us