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

Japanese text does not display correctly in a JEditorPane

XMLWordPrintable

    • b20
    • sparc
    • solaris_9

        The customer say we are currently localizing our product, using Java 1.5.0_11, to run within a Japanese environment. We have a rich text editor, which is essentially using a JEditorPane and an HTMLDocument, and we found in testing our localization changes that whenever we edit a document that contains pre-existing content, if we type Japanese text (using the Windows Japanese Input Method Editor (IME)) at the beginning of any of our lines, the text will not display to the end user until it has been committed (i.e. 'Enter' is pressed). Inputting Japanese text anywhere else but the beginning of the line will display properly (each character appears as you type it, even though it is still 'uncommitted'). Also, if you create a new line in your edit session, the text is displayed properly when entered, so the problem seems limited to the beginning of lines that existed prior to your editing session.

        This issue is reproducible on Solaris and Windows with 5.0 u11 and u14 and with 6.0 u2 and u3 with slight differences.

        1.5 == Beginning of line issue described above
        1.6 == Overstrikes chars -- does not shift chars to right

        The customer reports it is not a problem with their code. The way I was able to determine that it wasn't a problem with our code (and probably the easiest way for you to recreate the problem) was to test it within the demo program provided within the JDK. Within the
        SwingSet2 demo, there is an HtmlDemo which uses a JEditorPane and an HTMLDocument in read-only mode. I edited the HtmlDemo.java class to make the document editable, recompiled and re-inserted it into the SwingSet2.jar, and then ran the demo. Now, when I try to insert Japanese text into the document at the beginning of any line, the text is not displayed until I press 'Enter'. Then, comparing that to the behaviour of inserting text somewhere in the middle of a line, I can see the characters as I type them. The final thing to note is that if you go to the end of the document, press enter to create a new line, it behaves properly.
        Steps to reproduce the problem on Windows XP

        **NOTE** I have not been able to input Japanese chars on Solaris so
        I have not been able to reproduce on Solaris. Howver customer
        can since they have a japanese keyboard.
        **
        The way I was able to determine that it wasn't a problem with our code
        (and probably the easiest way for you to recreate the problem) was to
        test it within the demo program provided within the JDK. Within the
        SwingSet2 demo, there is an HtmlDemo which uses a JEditorPane and an
        HTMLDocument in read-only mode. I edited the HtmlDemo.java class to
        make the document editable, recompiled and re-inserted it into the
        SwingSet2.jar, and then ran the demo. Now, when I try to insert
        Japanese text into the document at the beginning of any line, the text
        is not displayed until I press 'Enter'. Then, comparing that to the
        behaviour of inserting text somewhere in the middle of a line, I can see
        the characters as I type them. The final thing to note is that if you
        go to the end of the document, press enter to create a new line, it
        behaves properly.
        **

        To get the Microsoft IME working (this is how to do it on XP, but I'm
        sure it will be similar for whatever flavour of Windows you're working
        with):

        There's two steps:
        1. Install the Language files
        - open Control Panel
        - open Regional and Language Options
        - go to the Languages tab
        - check the box that says "Install files for East Asian languages". You
        will probably need a Windows CD for this, as it will need to install
        some files that are probably not already on your machine. After this,
        it will ask you to restart for the installation to complete.

        2. Enable the Japanese IME
        - open Control Panel
        - open Regional and Language Options
        - go to the Languages tab
        - click on the "Details ..." button in the "Text services and input
        languages" subsection
        - click the "Add ..." button to add a new language input
        - select "Japanese" in the "Input Language" dropdown, and it should
        default to "Microsoft IME Standard 2002 ver 8.1" (or something similar)
        in the "Keyboard Layout/IME" dropdown
        - you should now see the language bar in your taskbar

        When you want to type using Japanese characters, simply put your cursor
        into the text field, click on the language bar to change between "EN"
        and "JP", and change the input mode (third button over) from "Direct
        Input" to "Hiragana" (Note: Japanese characters are usually created by
        typing a consonant followed by a vowel).

        If your language bar is too small, you may not see it. To make it
        bigger, you can hit the restore button (small icon on the top right of
        the language bar with tool tip text = "restore), and that should bring
        it out of the taskbar and make it full size (all buttons will be
        visible).

        The button you want looks like a very tall capital letter 'A'. If you
        hover over the button, it should give a tool tip text of "Input Mode".
        Clicking on this button will bring up a list of a number of Japanese
        dialects (I believe they're dialects ... not to sure about this. All I
        know is that we want Hiragana).

        To reiterate, the full language bar should have 11 buttons on it when in
        Japanese mode (4 of which are only half the height of the bar) - whereas
        when in English mode, there are only 4. The only two buttons you need
        to worry about are the English/Japanese selector and the Input Mode
        buttons.

        The Input Mode button is also on the language bar.

              gsm Sergey Groznyh (Inactive)
              tstatt Terry Statt (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: