Input/action map prob on JTextComponent
- From: Karsten Wutzke <kwutzke@xxxxxx>
- Date: Thu, 20 Mar 2008 17:11:31 -0700 (PDT)
Hello,
I use the following code to assign key strokes to actions to be
performed:
Action act = new ... (whatever)
JTextComponent tc = new ... (some standard text component)
Object key = action.getValue(Action.NAME);
tc.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,
0), key); <--- not working!
tc.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,
KeyEvent.CTRL_DOWN_MASK), key);
tc.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("alt
S"), key);
tc.getActionMap().put(key, caSend);
There's nothing basically wrong with the above code. When entering
something into the text component, the action atop is performed on Alt-
S or Ctrl-ENTER, however it is *NOT* performed when not using a
modifier. Might have to with the component being a text component. ->?
Why doesn't it work?
How do I make it work?
That text component is supposed to be single lined, but resizability
simply looks better with the app...
I've just tried using a JTextField instead and the RETURN only
keystroke *works*. Does anyone know why the former styled text pane/s
don't?
Karsten
.
- Follow-Ups:
- Re: Input/action map prob on JTextComponent
- From: Karsten Wutzke
- Re: Input/action map prob on JTextComponent
- Prev by Date: Re: Location of image files in Java SRC
- Next by Date: Re: Input/action map prob on JTextComponent
- Previous by thread: Images in text component (emoticons)
- Next by thread: Re: Input/action map prob on JTextComponent
- Index(es):