File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes The method KeyPressed(KeyEvent) from the type new KeyAdapter(){} is never used locally Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "The method KeyPressed(KeyEvent) from the type new KeyAdapter(){} is never used locally" Watch "The method KeyPressed(KeyEvent) from the type new KeyAdapter(){} is never used locally" New topic
Author

The method KeyPressed(KeyEvent) from the type new KeyAdapter(){} is never used locally

Nicol Green
Ranch Hand

Joined: Jan 30, 2010
Posts: 66
I have following code and for KeyPressed it shows me error: "The method KeyPressed(KeyEvent) from the type new KeyAdapter(){} is never used locally". I want to validate input in JFormattedTextField.



Why it cannot be read ?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36478
    
  16
Please check the spelling carefully; you don't usually start method names with capital letters. Put the @Override annotation before the heading of that method and see whether you are getting any compiler errors.
The problem with Adapter classes is that it is possible to miss such tiny errors, which mean the method you think is being called is never called. The @Override annotation should always be used to catch that problem.
Nicol Green
Ranch Hand

Joined: Jan 30, 2010
Posts: 66
hmm, what a shame..

Sorry, I really didn't noticed, it happens when you looking the same code over and over again..
Thanks!
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36478
    
  16
Lots and lots of people do that. That is nothing to worry about. Remember the @Override annotation.
Nicol Green
Ranch Hand

Joined: Jan 30, 2010
Posts: 66
Thanks!
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36478
    
  16
You're welcome.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: The method KeyPressed(KeyEvent) from the type new KeyAdapter(){} is never used locally
 
Similar Threads
KeyAdapter Problem, With Source Code
key update
doClick and trapping of enter key
What is wrong with this code?
key listener not detected