private void buildText(List<ElementSpec> elements, TextBox box) { String text = box.getText(); VisualContext vc = box.getVisualContext(); MutableAttributeSet attr = new SimpleAttributeSet(); attr.addAttribute(Constants.ATTRIBUTE_FONT_VARIANT, vc.getFontVariant()); attr.addAttribute(Constants.ATTRIBUTE_TEXT_DECORATION, vc.getTextDecoration()); attr.addAttribute(Constants.ATTRIBUTE_FONT, vc.getFont()); attr.addAttribute(Constants.ATTRIBUTE_FOREGROUND, vc.getColor()); attr.addAttribute(SwingBoxDocument.ElementNameAttribute, Constants.TEXT_BOX); attr.addAttribute(Constants.ATTRIBUTE_ANCHOR_REFERENCE, new Anchor()); attr.addAttribute(Constants.ATTRIBUTE_BOX_REFERENCE, box); // elements.add(new ElementSpec(attr, ElementSpec.StartTagType)); elements.add( new ElementSpec(attr, ElementSpec.ContentType, text.toCharArray(), 0, text.length())); // elements.add(new ElementSpec(attr, ElementSpec.EndTagType)); }