Solved

Multiple key strokes one action

Posted on 2007-11-22
3
633 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
countHi challenge 25 85
Java and GPO 11 47
backtracking recursion  code 19 41
VB Script to add site to Java Exception List 4 18
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
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.

760 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

22 Experts available now in Live!

Get 1:1 Help Now