Hi, Paul.
It sounds like the approach you've tried follows these lines:
(Don't let the inner class intimidate you, my putting it here arises out of convenience and not necessity.)
The problem is, the class's implementing of java.awt.event.KeyListener requires you to have a method with the signature
public void keyPressed( KeyEvent ke ), and it doesn't like
public void keyPressed( MyKeyEvent mke ).
If you try to compile this code, you'll get
But if you add
public void keyPressed( KeyEvent ke ), your code will never get called.
The solution, I think, Paul, is
not to
extend KeyEvent, but rather to "wrap" a
bona fide KeyEvent inside a class of your own design. This strategem is a design
pattern, called the "Decorator" or "Wrapper" design pattern.
In this case, instead of overriding or adding functionality in a subclass that you create, you make KeyEvent an instance variable to your class, and add functionality to your class by "decorating" that instance variable.
I hope that makes sense; all my little toy example does here is print to standard output the key you press while the frame is active.
Good luck, Paul.
Art
[This message has been edited by Art Metzer (edited May 25, 2001).]