• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java uses or overrides a deprecated API?  RSS feed

 
Deepak Aravind
Greenhorn
Posts: 3
Chrome Eclipse IDE MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got a warning message while compiling this Java file.. can any one assist me to overcome this?



The warning message is attached with screenshot


warning-message.jpg
[Thumbnail for warning-message.jpg]
Warning message
 
Dave Tolls
Ranch Foreman
Posts: 3065
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As described in the API.
"Deprecated. As of JDK version 1.1, should register this component as ActionListener on component which fires action events."

So you shouldn't be doing anything with the action() method, and instead be attaching an ActionListener.
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Where did you get that code example from? According to the JavaDocs, the action() method has been deprecated since Java 1.1, which means that its usage hasn't been recommended since 1997.

Question: Does it still work? Java is notorious for deprecating stuff, and never getting around to removing it ... so, it may still work...

Henry
 
Anayonkar Shivalkar
Bartender
Posts: 1558
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Deepak,

Welcome to CodeRanch!

Please UseCodeTags. I've added those for now.

I agree with Dave & Henry. It is not safe to use deprecated API.

However, if you simply want to get rid of that warning, then you can use annotation:for problematic method.
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry Wong wrote: . . . Java is notorious for deprecating stuff, and never getting around to removing it . . .
Backward compatibility. If they removed that method, code which has been running for 18 years would suddenly start throwing no such method exceptions.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!