Hi
I've got a class that extends JComponent.
The class implements KeyListener.
Nothing happens when I pless a key !!!
Any ideas why ?
NOTE: ShapeViewer extends JComponent !!!!!
Here is the code.
import java.awt.event.*;
public class ShapeEditor extends ShapeViewer implements KeyListener{
//Constructor(s)
public ShapeEditor(){
addListeners();
}
//Private Methods
private void addListeners(){
addKeyListener(this);
}
//Public Methods
//Overwrite Methods
//Keyboard Events
public void keyPressed(KeyEvent e){
//Invoked when a key has been pressed.
System.out.println("Key " + e.getKeyCode());
}
public void keyReleased(KeyEvent e){
//Invoked when a key has been released.
System.out.println("Key " + e.getKeyCode());
}
public void keyTyped(KeyEvent e){
//Invoked when a key has been typed.
System.out.println("Key " + e.getKeyCode());
}
}
Toyman
VB / Java Programmer
carel_dutoit@yahoo.co.uk
I've got a class that extends JComponent.
The class implements KeyListener.
Nothing happens when I pless a key !!!
Any ideas why ?
NOTE: ShapeViewer extends JComponent !!!!!
Here is the code.
import java.awt.event.*;
public class ShapeEditor extends ShapeViewer implements KeyListener{
//Constructor(s)
public ShapeEditor(){
addListeners();
}
//Private Methods
private void addListeners(){
addKeyListener(this);
}
//Public Methods
//Overwrite Methods
//Keyboard Events
public void keyPressed(KeyEvent e){
//Invoked when a key has been pressed.
System.out.println("Key " + e.getKeyCode());
}
public void keyReleased(KeyEvent e){
//Invoked when a key has been released.
System.out.println("Key " + e.getKeyCode());
}
public void keyTyped(KeyEvent e){
//Invoked when a key has been typed.
System.out.println("Key " + e.getKeyCode());
}
}
Toyman
VB / Java Programmer
carel_dutoit@yahoo.co.uk