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

TextField deletes multiline strings

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 7u65, 8, 9
    • Fix Version/s: 9
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b100
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      FULL PRODUCT VERSION :
      java version "1.7.0_65"
      Java(TM) SE Runtime Environment (build 1.7.0_65-b19)
      Java HotSpot(TM) Client VM (build 24.65-b04, mixed mode, sharing)
      and
      java version "1.8.0_11"
      Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
      Java HotSpot(TM) Client VM (build 25.11-b03, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      All Windows versions (x86/x64):
      - Microsoft Windows XP [Version 5.1.2600]
      - Microsoft Windows [Version 6.1.7601]
      - Microsoft Windows [Version 6.3.9600]

      A DESCRIPTION OF THE PROBLEM :
      Starting with java-version 1.7 the awt.TextField deletes all strings after the first row in a multiline string, if the method setText() is used. The data is lost! In java-versions from 1.1 to 1.6 the awt.TextField shows the whole multiline string.
      If the showing of the multiline string in java-versions 1.1 to 1.6 was an error which was corrected in version 1.7, I wonder why the awt.Label shows a multiline string in versions 1.7 and 1.8 like in versions 1.1 to 1.6. Shouldn't the display of awt.TextField and awt.Label not be the same after setText()?

      REGRESSION. Last worked in version 6u45

      ADDITIONAL REGRESSION INFORMATION:
      All java-versions until 1.7, for example:
      java version "1.6.0_03"
      Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
      Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile the example-program with java 1.6 and run it with versions 1.6, 1.7 and 1.8.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The contents of the awt.TextField and awt.Label should display the same in all java-versions.
      ACTUAL -
      The awt.TextField in java-versions 1.7 and 1.8 does not show the whole string.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;

      public class TextFieldBug extends Frame
      {
        public TextFieldBug()
        {
      this.setLayout(new GridLayout(2, 1, 5, 5));

      Label myLabel = new Label();
      TextField myTextField = new TextField();

      this.add( myLabel );
      this.add( myTextField );

      String myTwoRowsString = new String("Row 1 of 2");
      myTwoRowsString = myTwoRowsString + System.getProperty("line.separator");
      myTwoRowsString = myTwoRowsString + new String("Row 2 of 2");

      myLabel.setText( myTwoRowsString );
      myTextField.setText( myTwoRowsString );
         }

         public static void main(String[] args)
        {
      TextFieldBug myTextFieldBug = new TextFieldBug();
      myTextFieldBug.pack();
      myTextFieldBug.setVisible(true);
        }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Use an one-row awt.TextArea instead of an awt.TextField to avoid data loss.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                arapte Ambarish Rapte
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: