United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4841999 : Documentation of the label field for the default ctor of Button is wrong

Details
Type:
Bug
Submit Date:
2003-04-03
Status:
Resolved
Updated Date:
2003-05-25
Project Name:
JDK
Resolved Date:
2003-05-25
Component:
client-libs
OS:
generic
Sub-Component:
java.awt
CPU:
generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
5.0
Fixed Versions:
5.0 (tiger)

Related Reports

Sub Tasks

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



Hardware and Software, Engineered to Work Together