How do I set both StrikeThrough and Underline styling options for text inside a JTextPane?
I have a JTextPane component and I am trying to style the text that will be typed by the user to be both underline and strikethrough at the same time. The relevant snippet of code that that should set the strikethrough attribute of the next typed character to true is this: JEditorPane editor = getEditor(e); if (editor != null) { StyledEditorKit kit = getStyledEditorKit(editor); MutableAttributeSet attr = kit.getInputAttributes(); SimpleAttributeSet sas = new SimpleAttributeSet(); StyleConstants.setStrikeThrough(sas, true); setCharacterAttributes(editor, sas, false); } This does style the text