dcsimg

How do I insert a component into a JTextPane?

John Zukowski

Style style = document.addStyle("StyleName", null);
StyleConstants.setComponent(style, theComponent);
document.insertString(doc.getLength(), "text to be ignored", style);
Be sure to deal with the BadLocationException.