OSDN Git Service

Merged gcj-eclipse branch to trunk.
[pf3gnuchains/gcc-fork.git] / libjava / classpath / javax / swing / JTextPane.java
index c0a5f80..05968fc 100644 (file)
@@ -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);
   }
 
   /**