Re: Question about javax.swing example
zfkmk@yahoo.com wrote:
...
Is this a good or bad example?
Bad.
If bad, what is wrong with it?
<sscce>
import javax.swing.*;
class MyApp extends JFrame {
MyApp(String[] args) {}
public static void main(final String[] args) {
// Schedule a job for the event-dispatching thread:
// creating and showing this application's GUI.
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new MyApp(args).show();
}
});
}
}
</sscce>
D:\>javac MyApp.java
Note: D:\MyApp.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
D:\>javac -Xlint:deprecation MyApp.java
MyApp.java:13: warning: [deprecation] show() in
java.awt.Window has been deprecated
new MyApp(args).show();
^
1 warning
Which, when we check the JDocs indicates..
Deprecated. As of JDK version 1.5, replaced by setVisible(boolean).
When I stated that though, I (again) mistook it for the
Component.show() method deprecated in 1.1.
Either way, it is deprecated, and has been for the last
two Java releases.
So - it is bad for showing deprecated code in the package docs
of (a major part of) the official documentation for the language.
--
Andrew Thompson
http://www.athompson.info/andrew/
Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200711/1