StyleConstants: setIcon(MutableAttributeSet a, Icon c)
import javax.swing.ImageIcon;
import javax.swing.JTextPane;
import javax.swing.text.Style;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyledDocument;
public class Main {
public static void main(String[] argv) throws Exception{
JTextPane textPane = new JTextPane();
StyledDocument doc = (StyledDocument) textPane.getDocument();
Style style = doc.addStyle("StyleName", null);
StyleConstants.setIcon(style, new ImageIcon("imagefile"));
doc.insertString(doc.getLength(), "ignored text", style);
}
}
Related examples in the same category
| 1. | StyleConstants.Bold | | |
| 2. | StyleConstants.Foreground | | |
| 3. | StyleConstants.Italic | | |
| 4. | StyleConstants.LineSpacing | | |
| 5. | StyleConstants: setAlignment(MutableAttributeSet a, int align) | | |
| 6. | StyleConstants: setBold(MutableAttributeSet a, boolean b) | | |
| 7. | StyleConstants: setComponent(MutableAttributeSet a, Component c) | | |
| 8. | StyleConstants: setFirstLineIndent(MutableAttributeSet a, float i) | | |
| 9. | StyleConstants: setFontFamily(MutableAttributeSet a, String fam) | | |
| 10. | StyleConstants: setForeground(MutableAttributeSet a, Color fg) | | |
| 11. | StyleConstants: setFontSize(MutableAttributeSet a, int s) | | |
| 12. | StyleConstants: setItalic(MutableAttributeSet a, boolean b) | | |
| 13. | StyleConstants: setLeftIndent(MutableAttributeSet a, float i) | | |
| 14. | StyleConstants: setRightIndent(MutableAttributeSet a, float i) | | |
| 15. | StyleConstants: setSpaceAbove(MutableAttributeSet a, float i) | | |
| 16. | StyleConstants: setSpaceBelow(MutableAttributeSet a, float i) | | |
| 17. | StyleConstants: setTabSet(MutableAttributeSet a, TabSet tabs) | | |
| 18. | StyleConstants: setUnderline(MutableAttributeSet a, boolean b) | | |