?
Solved

Multiple key strokes one action

Posted on 2007-11-22
3
Medium Priority
?
674 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 200 total points
ID: 20335212
Try

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

Assisted Solution

by:contactkarthi
contactkarthi earned 200 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
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 will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month10 days, 14 hours left to enroll

770 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