JDK-6515713 : example in JFormattedTextField API docs instantiates abstract class
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: x86
  • Submitted: 2007-01-22
  • Updated: 2015-09-29
  • Resolved: 2015-01-20
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u60Fixed 9 b52Fixed
Description
A DESCRIPTION OF THE PROBLEM :
The API docs use the following code as example:
----------
JFormattedTextField tf = new JFormattedTextField();
tf.setValue(new Number(100));
----------
This is a bad example because it creates an instance of Number which is an abstract class. This code will never compile.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I expected working example code, e.g.
----------
JFormattedTextField tf = new JFormattedTextField();
tf.setValue(new Integer(100));
----------

ACTUAL -
JFormattedTextField tf = new JFormattedTextField();
tf.setValue(new Number(100));


URL OF FAULTY DOCUMENTATION :
http://java.sun.com/javase/6/docs/api/javax/swing/JFormattedTextField.html