C
CBrand
Hello all,
I would like to implement events on the same level as the component
that is listening for them. Is there any problem with subclassing a
Component that implements its own listeners? For example:
public class Foo extends JTextField implements KeyListener {
public Foo() {
super(32);
addKeyListener(this);
}
public void keyPressed(KeyEvent e) {
//Do stuff here.
}
public void keyReleased(KeyEvent e) {
//Do stuff here.
}
public void keyTyped(KeyEvent e) {
//Do stuff here.
}
}
I would like to implement events on the same level as the component
that is listening for them. Is there any problem with subclassing a
Component that implements its own listeners? For example:
public class Foo extends JTextField implements KeyListener {
public Foo() {
super(32);
addKeyListener(this);
}
public void keyPressed(KeyEvent e) {
//Do stuff here.
}
public void keyReleased(KeyEvent e) {
//Do stuff here.
}
public void keyTyped(KeyEvent e) {
//Do stuff here.
}
}