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

Composed characters not deleted correctly in JTextArea/TextArea

    Details

      Description

      OPERATING SYSTEM(S)
      Windows, Linux

      FULL JDK VERSION(S)
      Issue is present in latest 1.4.2, 5.0, 6 and 7.

      PROBLEM DESCRIPTION
      -------------------
      Deletion of composed characters is not correct in JTextArea and TextArea. Two problems are observed:

      1. Attempting to delete a composed character using the Delete key
         results in the accent being moved above the character to the left of
         the cursor, rather than being deleted along with the character to
         which the accent was originally attached.

      2. Attempting to delete a composed character with the backspace key
         requires two presses - with the first press the accent is deleted,
         with the second press the character underneath is deleted. Both
         should be deleted simultaneously.

      The problems are observed in both JTextArea and TextArea, but the situation differs slightly between Windows and Linux:

      Windows: Issue 1 observed with JTextArea only.
               Issue 2 observed with both JTextArea and TextArea.

        Linux: Both issues observed with both JTextArea and TextArea

      REPRODUCTION INSTRUCTIONS
      -------------------------

      1. Compile and run the testcase below. You will see four windows. The
         upper two windows contain Thai example text, and the lower two
         windows contains Latin example text. The two windows on the left are
         TextAreas, and the two on the right are JTextAreas. The rest of the
         instruction refer specifically to the Latin example, but the problem
         can be seen with both.

      2. To observe Issue 1, position the cursor after the "b" character press
         delete. Note that the "a" character is deleted, but the umlaut moves
         to a position above the "b" character. Repeat in both left and right
         windows.

      3. To observe Issue 2, position the cursor after the accented "a"
         character and press backspace. Note that only the umlaut is deleted.
         A second press of backspace removes the remaining "a" character.
         Repeat in both left and right windows.

      TESTCASE SOURCE
      ---------------
      ========================================================================
      import javax.swing.*;
      import java.awt.*;
      import java.util.Locale;

      public class TextDemo extends JFrame {
          TextDemo() {
              getContentPane().setLayout(new GridLayout(2,2));
              // Thai
              TextArea area = new TextArea(" \u0E02\u0E01\u0E34\u0E03 ");
              area.setEditable(true);
              area.setFont(new Font("Lucida Sans regular",Font.PLAIN,24));
              getContentPane().add(area);
              JTextArea ta = new JTextArea(" \u0E02\u0E01\u0E34\u0E03 ", 10,3);
              ta.setFont(new Font("Lucida Sans regular",Font.PLAIN,24));
              ta.setEditable(true);
              getContentPane().add(ta);
              // Latin
              area = new TextArea(" \u0062\u0061\u0308\u0063 ");
              area.setEditable(true);
              area.setFont(new Font("Lucida Sans regular",Font.PLAIN,24));
              getContentPane().add(area);
              ta = new JTextArea(" \u0062\u0061\u0308\u0063 ", 10, 3);
              ta.setFont(new Font("Lucida Sans regular",Font.PLAIN,24));
              ta.setEditable(true);
              getContentPane().add(ta);
          }

          public static void main(String[] args) {
              JFrame f= new TextDemo();
              f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              f.pack();
              f.setSize(400,400);
              f.setVisible(true);
          }
      }
      ========================================================================

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              dkorbel David Korbel (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Imported:
                Indexed: