summaryrefslogtreecommitdiff
path: root/javax/swing/JTextPane.java
diff options
context:
space:
mode:
Diffstat (limited to 'javax/swing/JTextPane.java')
-rw-r--r--javax/swing/JTextPane.java19
1 files changed, 5 insertions, 14 deletions
diff --git a/javax/swing/JTextPane.java b/javax/swing/JTextPane.java
index c0a5f80cf..05968fc8c 100644
--- a/javax/swing/JTextPane.java
+++ b/javax/swing/JTextPane.java
@@ -214,20 +214,11 @@ public class JTextPane
*/
public void insertIcon(Icon icon)
{
- SimpleAttributeSet atts = new SimpleAttributeSet();
- atts.addAttribute(StyleConstants.IconAttribute, icon);
- atts.addAttribute(StyleConstants.NameAttribute,
- StyleConstants.IconElementName);
- try
- {
- getDocument().insertString(getCaret().getDot(), " ", atts);
- }
- catch (BadLocationException ex)
- {
- AssertionError err = new AssertionError("Unexpected bad location");
- err.initCause(ex);
- throw err;
- }
+ MutableAttributeSet inputAtts = getInputAttributes();
+ inputAtts.removeAttributes(inputAtts);
+ StyleConstants.setIcon(inputAtts, icon);
+ replaceSelection(" ");
+ inputAtts.removeAttributes(inputAtts);
}
/**