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
|
|
0
|
|
|
|
Reply
|
kwutzke (87)
|
3/21/2008 12:11:31 AM |
|
On 21 Mrz., 01:11, Karsten Wutzke <kwut...@web.de> wrote:
> 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
Oops... the line
tc.getActionMap().put(key, caSend);
was supposed to be
tc.getActionMap().put(key, act);
Anyway the code is right and tested, since both other keystrokes
work...
Karsten
|
|
0
|
|
|
|
Reply
|
Karsten
|
3/21/2008 2:07:38 AM
|
|
|
1 Replies
104 Views
(page loaded in 0.028 seconds)
Similiar Articles: JTextField - how to disable selecting text in this component ...If this isn't the problem could you try and make the ... You will want to catch keyboard input also. (Block ... remove the cut copy and paste actions from the action map ... JTable and Enter key - comp.lang.java.guiThe action associated whith the enter key must be in one ... getKeyStroke(KeyEvent.VK_ENTER, 0); InputMap map ... and Enter key - comp.lang.java.gui How to capture input ... Odd BACKUP error: unsupported file structure ! - comp.os.vms ...... 11$DQB0:[ALLIN1.LIB_SHARE]BALLCAP.EPS;1 as input ... the FID was (58136,1,0); looks like a different problem. ... A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 6 =A0 =A0Trans= action ... [comp.publish.cdrom] CD-Recordable FAQ, Part 1/4 - comp.publish ...Archive-name: cdrom/cd-recordable/part1 Posting-Frequency: monthly Last-modified: 2008/10/09 Version: 2.71 Send corrections and updates to And... *** glibc detected *** gdb: malloc(): smallbin double linked list ...===== Memory map: ===== 00400000-00818000 r-xp 00000000 ... problem when writing extensions for languages with garbage ... #597 (Segv with GDAL input plugin) – Mapnik Wiki ... ... Future Terminal Emulator? - comp.unix.solaris... getting one's hands dirty writing shell scripts, action ... followup in the newsgroup] So what's the problem with ... that you guys are all sys-admins, have a lot of input ... OpenGL video rendering - comp.graphics.api.openglYou can see my app in action on TV on the web www ... Hello again, So, I could isolate the problem. It's ... I'm thinking on implementing my renderer with two input ... improve strlen - comp.lang.asm.x86... measurements would still be all over the map based on ... The problem is that no one writes > anything but trivial ... You need to preserve the state of the registers on input ... keyboard/mouse programming - comp.lang.asm.x86The problem disappeared after we told him that only USB ... it must run on each boot *or* there must be a port map ... of behaviour lest it be subject to further action for ... DRIVER ... - comp.protocols.snmphouston drivers license map houston drivers license ... Driver: You Are the Wheelman in the US), is a 1999 Action ... science ) A subroutine which handles a complete input ... JTextComponent (Java Platform SE 6)input method handling in JTextComponent; 5. keymap handling ... associated with this JTextComponent. Action[] ... loadKeymap(Keymap map, JTextComponent ... Google MapsReport a problem - Maps Labs - Help ... the details that are visible on the screen, use the "Print" link next to the map. 7/22/2012 8:35:14 AM
|