1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
package aa;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
public class ulysse extends JFrame implements ActionListener ,KeyListener{
public JPanel pan;
private JButton sortir = new JButton ("sortir");
public ulysse(){
this.setResizable(false);
this.setSize(620,620);
pan.setLayout(null);
sortir.addActionListener(this);
sortir.addKeyListener(this);
sortir.setBounds(300,400,100,300);
pan.add(sortir);
getContentPane().add(pan);
}
/** Handle the key typed event from the text field. */
public void keyTyped(KeyEvent e) {
displayInfo(e, "KEY TYPED: ");
}
/** Handle the key-pressed event from the text field. */
public void keyPressed(KeyEvent e) {
displayInfo(e, "KEY PRESSED: ");
}
/** Handle the key-released event from the text field. */
public void keyReleased(KeyEvent e) {
displayInfo(e, "KEY RELEASED: ");
} |