Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Nicol Green
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48441
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48441
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lots and lots of people do that. That is nothing to worry about. Remember the @Override annotation.
 
Nicol Green
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!
 
Campbell Ritchie
Sheriff
Posts: 48441
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic