Article View: borland.public.jbuilder.java.language
Article #18285Capturing keyevent
From: Dag Welinder
Date: Thu, 16 Jul 1998 00:00
Date: Thu, 16 Jul 1998 00:00
26 lines
1275 bytes
1275 bytes
I wrote an applet with a panel containing lots of components (panels,
buttons...) and I want the whole panel (or the whole applet) to respond
when the enter-key is pressed. I've tried
class myApplet xtends Applet implements KeyListener {
...
public void keyPressed (KeyEvent e) {
respond ();
}
...
}
but it won't work. I also tried to add an keyListener to the panel (and
the applet) with
panel1.addKeyListener (new KeyAdapter() {
public void keyPressed (KeyEvent e) {
System.out.println ("Knapp tryckt.");
}
});
with no positive effect... Do I have to add keyListeners to every single
component in my panel (>40 of them>, since it seems like only the one
with focus can respond, or how would I solve it?
Regards, Dag Welinder
Technical Details
Message-ID:
<35AE0B8B.186C89C1@telia.se>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,d272ee6b40f022d,start X-Google-Attributes: gidf74b3,public From: Dag Welinder <dag.x.welinder@telia.se> Subject: Capturing keyevent Date: 1998/07/16 Message-ID: <35AE0B8B.186C89C1@telia.se> X-Deja-AN: 372026099 Content-Transfer-Encoding: 7bit Organization: Another Netscape Collabra Server User Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language