import java.awt.*;
import java.awt.event.*;
public class interfacciaconeventi extends Frame implements KeyListener{
TextField casella;
public interfacciaconeventi(){
setBackground(Color.white);
setSize(700,550);
setLayout(new FlowLayout(FlowLayout.CENTER,15,10));
casella=new TextField(1);
add(casella);
casella.addKeyListener(this);
setVisible(true);
requestFocus();
}
public void keyTyped(KeyEvent ke){
if(ke.getKeyChar()=='q'){
setVisible(false);
System.exit(0);
}
}
public static void main(String args[]){
Frame f= new interfacciaconeventi();
}
}
Sto provando la gestione degli eventi per un textfield pero' mi da un errore quando implemento keylistener, ecco:
interfacciaconeventi is not abstract and does not override abstract method keyReleased(java.awt.event.KeyEvent) in java.awtevent.KeyListener
A pescindere da errori nel codice (sicuro!), perche' mi da errore quando implemento un interfaccia??
Grazie