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;
}
###@###.###
======================================================================
|
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
|