Article View: borland.public.jbuilder.java.swing
Article #13024Can't catch any KeyEvent from JText components
From: Vladimir Olenin
Date: Wed, 07 Oct 1998 00:00
Date: Wed, 07 Oct 1998 00:00
53 lines
2493 bytes
2493 bytes
This is a multi-part message in MIME format.
--------------858859C7DD87A2752DF6BD91
Content-Type: text/plain; charset=koi8-r
Content-Transfer-Encoding: 7bit
I got really strange results when tried to listen to KeyEvents from
JTextArea, JTextPane, etc. Actually the deal is that i didn't get any
result at all! I know 4 sure that an instance of KeyAdapter is
constructed, but none of its methods is called when i press a key.
Should i set a keymap? I think it's not necessary, since there must be a
default one. Then anyway how could i add an Action for KeyStroke? I
considered the following code to be appropriate 4 this purpose, but got
only NullPointerException.
Action action = new sendButtonAdapter();
Keymap keymap = typingArea.getKeymap();
KeyStroke key = KeyStroke.getKeyStrokeForEvent(
new KeyEvent(typingArea, KeyEvent.VK_ENTER, 0, 0,
KeyEvent.VK_ENTER));
keymap.addActionForKeyStroke(key, action);
So, definitely i'm doing smth wrong (or not?). But WHAT??? Well, that
was my question. Hope u would give me a hint.
PS: Actually customized DefaultStyledDocument with overridden
insertString() method do this task pretty good. But i'm just SO curious!
Anyway the solution must be simple.
--
=-+-=-+-=-+-=
Join in Java community now!
http://www.geocities.com/SiliconValley/Heights/9815
=-+-=-+-=-+-=
--------------858859C7DD87A2752DF6BD91
Content-Type: text/x-vcard; charset=koi8-r;
name="keenonjava.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Vladimir Olenin
Content-Disposition: attachment;
filename="keenonjava.vcf"
begin:vcard
n:Vladimir;Olenin
x-mozilla-html:FALSE
adr:version:2.1
version:2.1
email;internet:keenonjava@collegemail.com
note:Java programmer. Open for project development offers. See my home page at: http://www.geocities.com/SiliconValley/Heights/9815/
end:vcard
--------------858859C7DD87A2752DF6BD91--
Technical Details
Message-ID:
<361B4921.D25A820C@collegemail.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,8c2091517781a7ac,start X-Google-Attributes: gid111d45,public From: Vladimir Olenin <keenonjava@collegemail.com> Subject: Can't catch any KeyEvent from JText components Date: 1998/10/07 Message-ID: <361B4921.D25A820C@collegemail.com> X-Deja-AN: 398797621 X-Accept-Language: en,ru Content-Type: multipart/mixed; boundary="------------858859C7DD87A2752DF6BD91" Organization: Another Netscape Collabra Server User Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.swing