textPane.replaceSelection("1");
assertEquals(textPane.getStyledDocument().getCharacterElement(0).getAttributes(),
textPane.getStyledDocument().getCharacterElement(1).getAttributes());
textPane.select(0, 1);
textPane.replaceSelection("");
attrs = new SimpleAttributeSet();
StyleConstants.setUnderline(attrs, true);
textPane.getStyledDocument().insertString(0, "Hello!", attrs);
textPane.select(0, 0);
textPane.replaceSelection("1");
assertEquals(textPane.getStyledDocument().getCharacterElement(0).getAttributes(),
textPane.getStyledDocument().getCharacterElement(1).getAttributes());
textPane.select(0, 1);
textPane.replaceSelection("2");
assertEquals(textPane.getStyledDocument().getCharacterElement(0).getAttributes(),
textPane.getStyledDocument().getCharacterElement(1).getAttributes());
textPane.setCaretPosition(1);
textPane.insertIcon(MetalIconFactory.getFileChooserNewFolderIcon());
textPane.select(2, 2);
textPane.replaceSelection("3");
attrs = new SimpleAttributeSet(textPane.getStyledDocument().getCharacterElement(1)
.getAttributes());
assertAttrubutes(attrs, false, false, false, false, false, false);
assertNotNull(StyleConstants.getIcon(attrs));
attrs = new SimpleAttributeSet(textPane.getStyledDocument().getCharacterElement(2)
.getAttributes());
assertAttrubutes(attrs, false, false, false, false, false, false);
assertNull(StyleConstants.getIcon(attrs));
}