JDK-4510123 : JTextArea.setWrapStyleWord() cannot handle the composed string properly
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.0,1.4.1,1.4.2
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic,linux
  • CPU: generic,x86
  • Submitted: 2001-10-03
  • Updated: 2017-05-16
  • Resolved: 2003-07-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
5.0 tigerFixed
Related Reports
Duplicate :  
Relates :  
Description
Reproduction:

- Extract the attached test case, JTextAreaTest.java.
- Compile and Execute the test case.
  % java JTextAreaTest

The test case includes one line sentence which is composed of 1 byte characters
and 2 bytes characters but the word-wrapping is an unnatural.  It should be
wrapped one character at a time in Japanese.  And also the location of the caret
which pointed by mouse on the place wrapped and no characters is actually on the different place.

###@###.### 2001-10-03

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger FIXED IN: tiger INTEGRATED IN: tiger tiger-b11 VERIFIED IN: tiger-beta
24-08-2004

SUGGESTED FIX Name: pzR10082 Date: 06/05/2003 *** /net/crown/export1/zpm/webrev/src/share/classes/javax/swing/text/Utilities.java- Thu Jun 5 14:53:09 2003 --- Utilities.java Thu Jun 5 14:44:52 2003 *************** *** 190,197 **** /** * Determine where to break the given text to fit ! * within the the given span. This tries to find a ! * whitespace boundary. * @param s the source of the text * @param metrics the font metrics to use for the calculation * @param x0 the starting view location representing the start --- 190,196 ---- /** * Determine where to break the given text to fit ! * within the given span. This tries to find a word boundary. * @param s the source of the text * @param metrics the font metrics to use for the calculation * @param x0 the starting view location representing the start *************** *** 211,225 **** int txtCount = s.count; int index = Utilities.getTabbedTextOffset(s, metrics, x0, x, e, startOffset, false); - for (int i = txtOffset + Math.min(index, txtCount - 1); - i >= txtOffset; i--) { char ch = txt[i]; ! if (Character.isWhitespace(ch)) { ! // found whitespace, break here ! index = i - txtOffset + 1; ! break; ! } } return index; } --- 210,239 ---- int txtCount = s.count; int index = Utilities.getTabbedTextOffset(s, metrics, x0, x, e, startOffset, false); + + if (index >= txtCount - 1) { + return txtCount; + } + + for (int i = txtOffset + index; i >= txtOffset; i--) { char ch = txt[i]; ! if (ch < 256) { ! // break on whitespace ! if (Character.isWhitespace(ch)) { ! index = i - txtOffset + 1; ! break; ! } ! } else { ! // a multibyte char found; use BreakIterator to find line break ! BreakIterator bit = BreakIterator.getLineInstance(); ! bit.setText(s); ! int breakPos = bit.preceding(i + 1); ! if (breakPos > txtOffset) { ! index = breakPos - txtOffset; ! } ! break; ! } } return index; } ###@###.### ======================================================================
24-08-2004

WORK AROUND Use JTextPane, create a ViewFactory that uses LabelView for rendering, or set the i18n property of the document. ###@###.### 2001-10-03 You can set the i18n property by way of: textComponent.getDocument().putProperty("i18n", Boolean.TRUE); ###@###.### 2003-10-28
03-10-2001

EVALUATION WrappedPlainView is currently using whitespace to determine breaking, it should use BreakIterator if there are chars > 255 in the document. ###@###.### 2001-10-03
03-10-2001