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

REGRESSION: TextArea uses wrong location values

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.4.2
    • client-libs
    • x86
    • windows_xp



      Name: gm110360 Date: 05/05/2004


      FULL PRODUCT VERSION :
      java version "1.5.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32c)
      Java HotSpot(TM) Client VM (build 1.5.0-beta-b32c, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      // t is a TextArea
      t.replaceRange("",t.getSelectionStart(),t.getSelectionEnd());
      This code use to work as a "cut" function with JDK1.4.1 and earlier.
      Ever since JDK1.4.2 (and 1.5 beta) this does not work properly.
      The wrong text is cut.
      This happens if you cut in any line other than the first line.
      It seems to have something to do with endline chars.
      The cut position is out by 2*(lineNo).
      Either replace range method is broken, or getSelectionStart and getSelectionEnd use incorrect location values.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the sample code.
      Resize the frame so that it is big enough.
      Enter the following text
      000
      111
      222
      333
      444
      Hilight the row no1 row i.e. "222"
      click the button.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The row with "222" in it SHOULD be removed
      ACTUAL -
      The row with "333" disappears

      REPRODUCIBILITY :
      This bug can be reproduced always.

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

      public class Zook extends Frame {

      public Zook() {
      final TextArea t;
      add(t=new TextArea(50,50));
      setVisible(true);
      Button b = new Button("Cut text");
      b.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent ae) {
      t.replaceRange("",t.getSelectionStart(),t.getSelectionEnd());
      }
      });
      add(b,BorderLayout.SOUTH);
      }

      public static void main(String args[]) {
      new Zook();
      }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Use Jdk1.4.1 or earlier

      Release Regression From : 1.4.1
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.

      (Incident Review ID: 261088)
      ======================================================================

            kdmsunw Kdm Kdm (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: