Pessoal, como posso associar uma tecla de funcao diretamente a um JFrame ?
private void initialize(){
this.statusJPanel = new StatusJPanel();
this.setSize( Toolkit.getDefaultToolkit().getScreenSize() );
this.setContentPane( getTelaPdvJContentPane() );
this.setTitle("My View");
this.addKeyListener( new java.awt.event.KeyAdapter() {
public void keyPressed( java.awt.event.KeyEvent e ){
System.out.println( "keyPressed()" ); // TODO Auto-generated Event stub keyPressed()
if( e.getKeyCode() == Event.F2 ){
System.out.println( "F2 key pressed" ); // TODO Auto-generated Event stub keyPressed()
}
}
} );
}
O codigo acima nao funcionou. Obs: estou usando o Eclipse Visual Editor