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

Possible Regression : JTextfield cursor placement behavior algorithm has changed.

    XMLWordPrintable

    Details

    • Subcomponent:
    • Introduced In Build:
      b134
    • Introduced In Version:
      7
    • Resolved In Build:
      b145
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Description

      SYNOPSIS
      --------
      Possible Regression : JTextfield cursor placement algorithm is broken
      Behavior changed with b134 and then changed again at b140.


      OPERATING SYSTEM
      ----------------
      ALL


      FULL JDK VERSION
      ----------------
      JDK 7 b134 onwards. Reproducible with latest, b142.
      Not reproducible with b133 and earlier.
      Not reproducible JDK 6u25.


      DESCRIPTION from LICENSEE
      -------------------------
      The behaviour of JTextField's cursor positioning algorithm has changed or has broken from JDK 7 b134 onwards. (Note that other components may also be affected - I've only tested with JTextField.) The exact symptoms change slightly in recent builds. Here are the details:

      Behaviour in JDK 7b134-b139

      If the mouse is clicked when the pointer is touching any part of a character, the cursor will be placed in between that character and the one preceding it - even if the pointer was only one pixel away from the gap between that character and the one after it. For example, consider the String "abcdefg". If you try to place the cursor between 'c' and 'd', the pointer is placed between 'b' and 'c' instead.

      Behaviour in JDK 7 b140 onwards.

      If the mouse is clicked when the pointer is touching any part of a character, the cursor will be placed in between that character and the one preceding it - even if the pointer was only one pixel away from the gap between that character and the one after it. For example, consider the String "abcdefg". If you try to place the cursor between 'c' and 'd', but the pointer is in the space occupied by the 'c', even its right-most extremity, the pointer will be placed between 'b' and 'c' instead. This is better than the situation in b133-b139, but still unintuitive and incorrect.

      REPRODUCTION INSTRUCTIONS
      -------------------------
      1. Compile and run the attached testcase
      2. Try to place the cursor in between any two of the characters.

      Observed behaviour (b134-b139):
      The cursor is not positioned in the position to left of the expected position.

      Observed behaviour (b140 onwards):
      The cursor is not positioned in the expected place if the mouse pointer is positioned slightly to the left of the intended position.

      Expected behaviour:
      The cursor should be placed in the correct place i.e. the nearest possible position to the mouse pointer's location. This is the behaviour in b133 and earlier, and in Java 6.

      TESTCASE
      --------
      import javax.swing.*;
      import java.awt.event.*;

      class TextFieldTest extends JFrame {

          TextFieldTest() {
              this.add(new JTextField("abcdefg"));
              setSize(150, 55);
              addWindowListener(new WindowAdapter() {
                                    public void windowClosing(WindowEvent e) { System.exit(0);}
                                });
              setVisible(true);
          }

          public static void main(String[] args) {
              new TextFieldTest();
          }
      }

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              rupashka Pavel Porvatov (Inactive)
              Reporter:
              dkorbel David Korbel (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: