private void buildBlockReplacedBox(List<ElementSpec> elements, BlockReplacedBox box) { // some content org.w3c.dom.Element elem = box.getElement(); String text = ""; // add some textual info, if picture if ("img".equalsIgnoreCase(elem.getTagName())) { text = " [" + elem.getAttribute("alt") + " Location: " + elem.getAttribute("src") + "] "; } MutableAttributeSet attr = new SimpleAttributeSet(); attr.addAttribute(SwingBoxDocument.ElementNameAttribute, Constants.BLOCK_REPLACED_BOX); attr.addAttribute(Constants.ATTRIBUTE_BOX_REFERENCE, box); attr.addAttribute(Constants.ATTRIBUTE_ANCHOR_REFERENCE, new Anchor()); attr.addAttribute(Constants.ATTRIBUTE_REPLACED_CONTENT, box.getContentObj()); elements.add( new ElementSpec(attr, ElementSpec.ContentType, text.toCharArray(), 0, text.length())); }