JDK-4841999 : Documentation of the label field for the default ctor of Button is wrong
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 5.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2003-04-03
  • Updated: 2017-05-16
  • Resolved: 2003-05-25
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 Availabitlity Release.

To download the current JDK release, click here.
Other
5.0 tigerFixed
Description
This was filed because it matches a similar JCK issue for Checkbox: 4632623 

The ctor for java.awt.Button says 

    /**
     * Constructs a Button with no label.
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
     * returns true
     * @see java.awt.GraphicsEnvironment#isHeadless
     */
    public Button() throws HeadlessException {
        this("");
    }

"No label" is taken to mean that the value is null elsewhere in Button.java 
and other classes.  In fact, the label is the empty string, and we should 
say so explicitly.  

This ctor needs to be changed as well: 

    /**
     * Constructs a Button with the specified label.
     * @param label A string label for the button.
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
     * returns true
     * @see java.awt.GraphicsEnvironment#isHeadless
     */
    public Button(String label) throws HeadlessException {
        GraphicsEnvironment.checkHeadless();
        this.label = label;
    }

It should say: 

@param label  a string label for the button, or <code>null</code> for no label 


The field description needs to be fixed as well: 

   /*
    * The button's Label.
    * If the Label is not specified it will default to "".
        * @serial
    * @see getLabel()
    * @see setLabel()
    */

We should remove the comment about the default, and simply state that this 
value may be null.  

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger FIXED IN: tiger INTEGRATED IN: tiger tiger-b08
2004-06-14

SUGGESTED FIX echawkes@gradgrind:/net/jano/export/disk26/awt/echawkes/jdk15-3/src/share/classes/java/awt( 57 )% sccs diffs -C Button.java ------- Button.java ------- *** /tmp/sccs.vFaaYs Sun Apr 20 12:28:31 2003 --- Button.java Wed Apr 2 20:13:30 2003 *************** *** 69,92 **** */ public class Button extends Component implements Accessible { ! /* ! * The button's Label. ! * If the Label is not specified it will default to "". ! * @serial ! * @see getLabel() ! * @see setLabel() ! */ ! String label; ! /* ! * The action to be performed once a button has been ! * pressed. ! * actionCommand can be null. ! * @serial ! * @see getActionCommand() ! * @see setActionCommand() ! */ ! String actionCommand; transient ActionListener actionListener; private static final String base = "button"; --- 69,91 ---- */ public class Button extends Component implements Accessible { ! /** ! * The button's label. This value may be null. ! * @serial ! * @see getLabel() ! * @see setLabel() ! */ ! String label; + /** + * The action to be performed once a button has been + * pressed. This value may be null. + * @serial + * @see getActionCommand() + * @see setActionCommand() + */ + String actionCommand; + transient ActionListener actionListener; private static final String base = "button"; *************** *** 108,119 **** /** * Initialize JNI field and method IDs for fields that may be ! accessed from C. */ private static native void initIDs(); /** ! * Constructs a Button with no label. * @exception HeadlessException if GraphicsEnvironment.isHeadless() * returns true * @see java.awt.GraphicsEnvironment#isHeadless --- 107,119 ---- /** * Initialize JNI field and method IDs for fields that may be ! * accessed from C. */ private static native void initIDs(); /** ! * Constructs a button with an empty string for its label. ! * * @exception HeadlessException if GraphicsEnvironment.isHeadless() * returns true * @see java.awt.GraphicsEnvironment#isHeadless *************** *** 123,130 **** } /** ! * Constructs a Button with the specified label. ! * @param label A string label for the button. * @exception HeadlessException if GraphicsEnvironment.isHeadless() * returns true * @see java.awt.GraphicsEnvironment#isHeadless --- 123,132 ---- } /** ! * Constructs a button with the specified label. ! * ! * @param label a string label for the button, or ! * <code>null</code> for no label * @exception HeadlessException if GraphicsEnvironment.isHeadless() * returns true * @see java.awt.GraphicsEnvironment#isHeadless
2004-06-11

EVALUATION Commit to fix in Tiger. ###@###.### 2003-04-02
2003-04-02