Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
0d06dbab
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
3
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0d06dbab
编写于
9月 07, 2009
作者:
G
gsm
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6699856: Creating text in a JTextPane using Chinese text causes undesired behavior
Reviewed-by: peterz
上级
2ef9119c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
31 addition
and
2 deletion
+31
-2
src/share/classes/javax/swing/JEditorPane.java
src/share/classes/javax/swing/JEditorPane.java
+5
-0
src/share/classes/javax/swing/JTextPane.java
src/share/classes/javax/swing/JTextPane.java
+5
-0
src/share/classes/javax/swing/text/JTextComponent.java
src/share/classes/javax/swing/text/JTextComponent.java
+21
-2
未找到文件。
src/share/classes/javax/swing/JEditorPane.java
浏览文件 @
0d06dbab
...
...
@@ -1125,6 +1125,7 @@ public class JEditorPane extends JTextComponent {
* @param content the content to replace the selection with. This
* value can be <code>null</code>
*/
@Override
public
void
replaceSelection
(
String
content
)
{
if
(!
isEditable
())
{
UIManager
.
getLookAndFeel
().
provideErrorFeedback
(
JEditorPane
.
this
);
...
...
@@ -1135,6 +1136,7 @@ public class JEditorPane extends JTextComponent {
try
{
Document
doc
=
getDocument
();
Caret
caret
=
getCaret
();
boolean
composedTextSaved
=
saveComposedText
(
caret
.
getDot
());
int
p0
=
Math
.
min
(
caret
.
getDot
(),
caret
.
getMark
());
int
p1
=
Math
.
max
(
caret
.
getDot
(),
caret
.
getMark
());
if
(
doc
instanceof
AbstractDocument
)
{
...
...
@@ -1150,6 +1152,9 @@ public class JEditorPane extends JTextComponent {
getInputAttributes
());
}
}
if
(
composedTextSaved
)
{
restoreComposedText
();
}
}
catch
(
BadLocationException
e
)
{
UIManager
.
getLookAndFeel
().
provideErrorFeedback
(
JEditorPane
.
this
);
}
...
...
src/share/classes/javax/swing/JTextPane.java
浏览文件 @
0d06dbab
...
...
@@ -170,6 +170,7 @@ public class JTextPane extends JEditorPane {
*
* @param content the content to replace the selection with
*/
@Override
public
void
replaceSelection
(
String
content
)
{
replaceSelection
(
content
,
true
);
}
...
...
@@ -183,6 +184,7 @@ public class JTextPane extends JEditorPane {
if
(
doc
!=
null
)
{
try
{
Caret
caret
=
getCaret
();
boolean
composedTextSaved
=
saveComposedText
(
caret
.
getDot
());
int
p0
=
Math
.
min
(
caret
.
getDot
(),
caret
.
getMark
());
int
p1
=
Math
.
max
(
caret
.
getDot
(),
caret
.
getMark
());
AttributeSet
attr
=
getInputAttributes
().
copyAttributes
();
...
...
@@ -197,6 +199,9 @@ public class JTextPane extends JEditorPane {
doc
.
insertString
(
p0
,
content
,
attr
);
}
}
if
(
composedTextSaved
)
{
restoreComposedText
();
}
}
catch
(
BadLocationException
e
)
{
UIManager
.
getLookAndFeel
().
provideErrorFeedback
(
JTextPane
.
this
);
}
...
...
src/share/classes/javax/swing/text/JTextComponent.java
浏览文件 @
0d06dbab
...
...
@@ -4815,7 +4815,18 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
new
AttributedString
(
text
,
composedIndex
,
text
.
getEndIndex
()));
}
private
boolean
saveComposedText
(
int
pos
)
{
/**
* Saves composed text around the specified position.
*
* The composed text (if any) around the specified position is saved
* in a backing store and removed from the document.
*
* @param pos document position to identify the composed text location
* @return {@code true} if the composed text exists and is saved,
* {@code false} otherwise
* @see #restoreComposedText
*/
protected
boolean
saveComposedText
(
int
pos
)
{
if
(
composedTextExists
())
{
int
start
=
composedTextStart
.
getOffset
();
int
len
=
composedTextEnd
.
getOffset
()
-
...
...
@@ -4830,7 +4841,15 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
return
false
;
}
private
void
restoreComposedText
()
{
/**
* Restores composed text previously saved by {@code saveComposedText}.
*
* The saved composed text is inserted back into the document. This method
* should be invoked only if {@code saveComposedText} returns {@code true}.
*
* @see #saveComposedText
*/
protected
void
restoreComposedText
()
{
Document
doc
=
getDocument
();
try
{
doc
.
insertString
(
caret
.
getDot
(),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录