Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4150122

TextComponent(text) and TextComponent.setText(t) work inconsistently

XMLWordPrintable

    • 1.2fcs
    • sparc
    • solaris_2.5
    • Verified



      Name: dsC58869 Date: 06/18/98



      The bug has been introduced into JDK-1.2beta4-J release.

      The constructor TextComponent(String text) and method
      TextComponent.setText(String t) work inconsistently with null parameter.
      The constructor sets text field to null, but the method to empty string.
       
      ==== Here is the test demonstrating the bug ====
      import java.awt.*;

      public class Test{
          
          public static void main(String[] args){
      String text = null;
      TextComponent tc = new TextArea(text);
      System.out.println("Text:" + tc.getText());
      tc.setText(text);
      System.out.println("Text:" + tc.getText());
          }
      }

      ==== Here is the output of the test ====
      %java Test
      Text:null
      Text:
      ^C
      ======================================================================
       Justification:
      The constructor and method sould work consistently

      ======================================================================

            dmendenhsunw David Mendenhall (Inactive)
            dsilaev Dmitri Silaev
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: