|
Quick Lists
|
|
Bug ID:
|
6699856
|
|
Votes
|
0
|
|
Synopsis
|
Creating text in a JTextPane using Chinese text causes undesired behavior
|
|
Category
|
java:classes_swing
|
|
Reported Against
|
|
|
Release Fixed
|
6u7-rev(b14)
|
|
State
|
10-Fix Delivered,
bug
|
|
Priority:
|
3-Medium
|
|
Related Bugs
|
|
|
Submit Date
|
09-MAY-2008
|
|
Description
|
FULL PRODUCT VERSION :
Java Plug-in 1.6.0_06
ADDITIONAL OS VERSION INFORMATION :
Windows XP Professional ver 2002 Service Pack 2
A DESCRIPTION OF THE PROBLEM :
A user selects the following language for their system:
Input language: Chinese (Taiwan)
Keyboard layout/IME: Chinese (Traditional) - Quick
When typing text into a JTextPane, some characters will be selected in blue to indicate they can be changed into other Chinese characters. If the user presses enter when the last character or two characters are selected (by Java to indicate they can be changed using the IME) the cursor will appear on a new line. When the user presses a key, the cursor will change the selected character/s on the previous line and return the cursor to this line.
When using other applications such as customer Notepad or Word, pressing enter and typing text will neither change the text on the previous line or move the cursor to the previous line.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Open the webpage:
http://java.sun.com/docs/books/tutorial/uiswing/components/editorpane.html
2. Click the 'Launch' button to load the webstart application.
3. Click in the bottom right editable pane.
4. Delete all content from the pane.
5. Change your input language to Chinese (Taiwan), keyboard input to Chinese (Traditional) - Quick.
6. Press the keys A, S, D. Press enter and you'll be taken to a new line. Press A and the text on line will change and the carat will be repositioned on line 1.
Try this functionality in customer Word or notepad to see the difference.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
New text should appear on the second line.
ACTUAL -
Text on line one changes and the carat is repositioned to line 1.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
http://java.sun.com/docs/books/tutorial/uiswing/examples/components/TextSamplerDemoProject/src/components/TextSamplerDemo.java
---------- END SOURCE ----------
Posted Date : 2008-05-09 16:36:35.0
|
|
Work Around
|
N/A
|
|
Evaluation
|
This behavior is caused by the fact that JTextPane (and JEditorPane) don't honor composed text in their replaceSelection() methods that they override from JTextComponent. The JTextComponent itself properly handles composed text, this is why, for example, this bug doesn't show in JTextAred (which doesn't override replaceSelection().)
Unfortunately JTextComponent doesn't expose its methods saveComposedText() and restoreComposedText() to subclasses, they are private.
The "right" way is to make these methods protected and thus available to subclasses. Unfortunately, this isn't possible in the update releases. This means that subclasses should either re-implement all the composed text machinery, which is pretty complex, or find some ways to access these private methods.
The obvious solution is to use reflection, but this is only a partial solution and won't work under security manager.
Another solution is to register some publicly accessible methods that "call back" into JTextComponent and invoke the corresponding private methods. I decided to use this way.
The publicly accessible methods live in SwingUtilities2, and JTextComponent registers a couple of closures there that just call back and invoke the required methods. JTextPane and JEditorPane then are able to use the methods from SwingUtilities2.
Posted Date : 2008-09-02 11:09:10.0
Well, after a long thought I finally decided to use reflection, as it allows to shorten the list of affected classes by two times.
Posted Date : 2008-09-04 13:29:34.0
|
|
Comments
|
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|
|
|
 |