Solved

Multiple key strokes one action

Posted on 2007-11-22
3
642 Views
Last Modified: 2012-06-21
I want to be able to bind more than one keystroke to the one action. The code below will bind ctrl+c to the action copyText. How can I also bind ctrl+ins to this?
KeyStroke controlC = KeyStroke.getKeyStroke("control C");  

Action copyText = textPane.getActionMap().get(textPane.getInputMap().get(controlC));

Open in new window

0
Comment
Question by:tomcorcoran
3 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 50 total points
ID: 20335212
Try

getKeyStroke(KeyEvent.VK_INSERT, InputEvent.CTRL_MASK);
0
 
LVL 17

Assisted Solution

by:contactkarthi
contactkarthi earned 50 total points
ID: 20336203
Here are some examples:

     "INSERT" => getKeyStroke(KeyEvent.VK_INSERT, 0);
     "control DELETE" => getKeyStroke(KeyEvent.VK_DELETE, InputEvent.CTRL_MASK);
     "control INSERT" => getKeyStroke(KeyEvent.VK_INSERT, InputEvent.CTRL_MASK);
     "alt shift X" => getKeyStroke(KeyEvent.VK_X, InputEvent.ALT_MASK | InputEvent.SHIFT_MASK);
     "alt shift released X" => getKeyStroke(KeyEvent.VK_X, InputEvent.ALT_MASK | InputEvent.SHIFT_MASK, true);
     "typed a" => getKeyStroke('a');
 
0
 

Author Closing Comment

by:tomcorcoran
ID: 31656913
Thanks guys, I,'m sure they answered the question I asked but the correct answer for me is to use the DefaultEditorKit
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
java  and programming certification ? 4 86
Java passing arguments (type error) 2 48
Error with Java/Cache JDBC Classpath 2 31
how to add new optional parameter to JSP 1 29
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now