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

ENHANCMENT: Add Word-Wise drag selection to TextFields

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 6u21
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:

      Description

      A DESCRIPTION OF THE REQUEST :
      When a user double-clicks on a word in the middle of a TextField, then drags the mouse, the highlighted portion is character by character and if dragging to the left, the caret/dot move away from the originally selected word.




      JUSTIFICATION :
      This is the default selection behavior for all Swing JTextComponents. More sophisticated components install their own mouse listeners to obtain this drag-selection behavior where the caret/dot stay to the end of the initial selection upon a drag-selection.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I would like to be able to turn on word wise selection. So that when double clicking then dragging to the left, the initial word stays completely highlighted and as the cursor moves to the left full words become selected.
      ACTUAL -
      When a user double-clicks on a word in the middle of a TextField, then drags the mouse, the highlighted portion is character by character and if dragging to the left, the caret/dot move away from the originally selected word.

      ---------- BEGIN SOURCE ----------
      import javax.swing.*;


      /*
      Double click on the word 'two' in the TextField the before releasing on the second click, drag to the left. The cursor/dot will follow the mouse, deselecting the word 'two'
      */

      public class TestDragSelection {
          public static void main(String[] args) {
              JFrame frame = new JFrame();
              JTextField field = new JTextField("one two three");

              frame.add(field);

              frame.setVisible(true);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.pack();
          }
      }
      ---------- END SOURCE ----------

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Imported:
                Indexed: