Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

What should go inside the braces of e.isControlDown()?
Thanks
Jack
 
Campbell Ritchie
Sheriff
Pie
Posts: 50232
79
  • Mark post as helpful
  • send pies
  • 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.
 
Manuel Petermann
Ranch Hand
Posts: 177
Hibernate Linux Python
  • Mark post as helpful
  • send pies
  • 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.
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • 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
  • 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: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic