Typing in JTextField doesn't always clear selection

XMLWordPrintable

      A DESCRIPTION OF THE PROBLEM :
      After selecting the first few characters in a JTextField from right to left, the selection remains after further character input. The selection is then replaced with every subsequent character typed.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Create a JTextField
      2. Type some characters into the field
      3. Select the first few characters from right to left (executing the selection more quickly seems to increase the chance of the bug occurring)
      4. Type some more characters into the field

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The first character entry should replace the selection and position the caret to the right side of inserted character with no active selection. All subsequent character entries should be inserted at the caret, moving the caret to the right.
      ACTUAL -
      When the bug occurs, every subsequent character entry selects itself (from right to left) after insertion, instead of clearing the selection and positioning the caret to its right side.

      ---------- BEGIN SOURCE ----------
      import javax.swing.JFrame;
      import javax.swing.JTextField;

      public class Test {
        public static void main(String[] args) {
          JFrame frame = new JFrame();

          frame.add(new JTextField());
          frame.pack();

          frame.setVisible(true);
        }
      }
      ---------- END SOURCE ----------

            Assignee:
            Praveen Narayanaswamy
            Reporter:
            Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: