2012-06-27 23 views
2

Thanks to devsundar我找到了如何在JEditorPane加粗/下划线/斜体/不管怎么做。我如何设置JEditorPane中所选文字的Font SizeJava - 在JEditorPane中设置选择的字体大小?

我对不断变化的粗体/斜体/等当前的方法:

AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, 
    StyleConstants.StrikeThrough, true); 

pane.getStyledDocument().setCharacterAttributes(pane.getSelectionStart(), 
    pane.getSelectionEnd(), aset, true); 

回答

3

有一个工作示例hereStyledEditorKit使用StyledEditorKit.FontSizeAction和相关类。

image

+0

我确实需要按钮添加到我的GUI,所以这将工作!谢谢! – Primm

+0

优秀;另见'HTMLDocumentEditor',在[这里]提到(http://stackoverflow.com/a/10160836/230513)。 – trashgod