• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to detect the key combination of ctrl-v has been pressed down?

 
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

What should go inside the braces of e.isControlDown()?
Thanks
Jack
 
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Go through the Java Tutorials with ctrl-F key and you find several things, about 5. I think these will be useful: 1 2.
 
Ranch Hand
Posts: 177
Hibernate Python Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want to use it for clipboard support. You might find Clipboard interesting.
By the way I never worked with it and don't know if you should use it any longer.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jacky Luk wrote:



When posting code on a forum, it's a good idea to remove inane IDE-generated comments which only add clutter.

It is never necessary to import classes from the java.lang package as the compiler automatically inserts an import-on-demand for java.lang.*

Rather than write your own empty implementations of all 3 KeyListener methods, you can extend KeyAdapter -- see the API.

If this is a Swing application, Kay Bindings are the way to go. Campbell has already posted a link to that particular section of the tutorials.
 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

A breakpoint in the code inside the Action event handler is never hit when I press ctrl-V. Why is that? I am sure I called addBindings()
 
Darryl Burke
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looks like you didn't go through all of the Key Binding tutorial

Hint: ActionMap
 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Darryl Burke wrote:Looks like you didn't go through all of the Key Binding tutorial

Hint: ActionMap



Fine now. But the only problem is that the binding only happens once when I call this ActionMap + InputMap once in the constructor, do I have to hook this map to somewhere?
Thanks
Jack
reply
    Bookmark Topic Watch Topic
  • New Topic