dcsimg
KeyListener
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Wolfgang_Klein
Posted On:   Tuesday, October 30, 2001 04:19 AM

I've got the following problem:
I write an object extending JComponent and want to
add a KeyListener, so i implemented the KeyListener methods
and wrote mycomp.addKeyListener ( this );
But pressing a key, nothing happens.
It only works if i attach the KeyListener to the JFrame-
class, but i want to include the code in the
JComponent Class itself.

Can anybody help ?

W.K

Re: KeyListener

Posted By:   Uwe_Freising  
Posted On:   Wednesday, October 31, 2001 05:26 AM

What is this in mycomp.addKeyListener (this)?. If mycomp is your derived component you
have to write mycomp.addKeyListener(mycomp) or better call addKeyListener
inside the code of the class mycomp is
an instance of.
About | Sitemap | Contact