首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

关于JTextPane的setLeftIndent 没实现缩进

2012-11-16 
关于JTextPane的setLeftIndent 没有实现缩进我用下面的一段代码,发现我可以加粗,设置字体大小,改变颜色,但

关于JTextPane的setLeftIndent 没有实现缩进
我用下面的一段代码,发现我可以加粗,设置字体大小,改变颜色,但是如果是缩进,或者是行距什么的
却无法实现,我不懂为什么会这样,有知道的人能帮帮忙说一下原因吗?


SimpleAttributeSet attrSet = new SimpleAttributeSet(); 
StyleConstants.setLeftIndent(attrSet, 30); //无法实现缩进
StyleConstants.setBold(attrSet, true); //可以实现字体加粗
StyleConstants.getLeftIndent(attrSet); //得到值是30
Document doc = msgArea.getDocument();  
try {  
  doc.insertString(doc.getLength(), "要缩进的字符", attrSet);  
}catch (BadLocationException e) {  
  System.out.println("BadLocationException: " + e);  
}



[解决办法]
可以看一下这个例子:

http://www.java2s.com/Code/JavaAPI/javax.swing.text/StyleConstantssetLeftIndentMutableAttributeSetafloati.htm

热点排行