aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes keyPressed method is called twice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "keyPressed method is called twice" Watch "keyPressed method is called twice" New topic
Author

keyPressed method is called twice

Rami Nassar
Greenhorn

Joined: Feb 23, 2011
Posts: 16

I override method keyPressed on my swing dialog but its called twice, can any one give me a hint?!!

/**
* Invoked when a key has been pressed.
* See the class description for {@link KeyEvent} for a definition of
* a key pressed event.
*/
public void keyPressed(KeyEvent ke) {
if( ke.getKeyCode() == KeyEvent.VK_F2) {
updateButtonactionPerformed();
} else if( ke.getKeyCode() == KeyEvent.VK_F3) {
openBiddingButtonactionPerformed();
} else if( ke.getKeyCode() == KeyEvent.VK_F4) {
deleteButtonactionPerformed();
} else if( ke.getKeyCode() == KeyEvent.VK_F5) {
closeButtonactionPerformed();
} else if( ke.getKeyCode() == KeyEvent.VK_F6) {
openAuctionPlatesLookup();
} else if( ke.getKeyCode() == KeyEvent.VK_RIGHT) {
populatePreviousPlate();
} else if( ke.getKeyCode() == KeyEvent.VK_LEFT) {
populateNextPlate();
}
}
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
have you added the listener twice?
Rami Nassar
Greenhorn

Joined: Feb 23, 2011
Posts: 16
Michael Dunn wrote:have you added the listener twice?



OMG.. yes I added it twice by mistake.. I remove it and its working fine.. thanks alot my friend :)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: keyPressed method is called twice