看來我目前的JTextArea實例的行間距約爲1或1.5。任何人都可以告訴我如何更改JTextArea實例中的行距?JTextArea中的行間距
6
A
回答
11
做谷歌搜索建議你應該使用JTextPane
,特別是setParagraphAttributes
位於here。
的方式來獲得AttributeSet
你需要如下:
MutableAttributeSet set = new SimpleAttributeSet();
StyleConstants.setLineSpacing(set, /* your spacing */);
現在只要在set
傳遞給setParagraphAttributes
方法。
希望這會有所幫助。
+1
很好的答案;但是,我建議從文本窗格中抓取當前的AttributeSet,而不是創建一個新的,這樣你只需要改變你關心的屬性,其他的將保持不變,如下所示: 'MutableAttributeSet set = new SimpleAttributeSet(textPane .getParagraphAttributes());' – Michael 2013-05-13 21:17:21
相關問題
- 1. iText列表項目或JTextArea中的行間距
- 2. 在JTextArea中添加邊距?
- 3. 設置JTextarea的行空間
- 4. JTextArea中的行
- 5. JTextArea中的新行?
- 6. BI Publisher中的行間距
- 7. Swift中的NSTextField行間距
- 8. SQL中的行間距
- 9. JtextArea中的時間格式
- 10. HTML - 表中的行之間的間距
- 11. 行之間的間距
- 12. 在JTextArea(而不是JTextPane)中更改行距
- 13. HTML行間距
- 14. UILabel行間距
- 15. qplaintextedit行間距
- 16. 行間距NSTextView
- 17. CoreText:行間距
- 18. 將矢量打印到JTextArea時發生間距錯誤
- 19. 刪除JTextArea中的行
- 20. XML:元素之間的水平間距和行間距
- 21. NSString sizeWithFont行間距
- 22. 行間距HTMLEditor JavaFx
- 23. UIButton的標題行間距
- 24. Linux終端中的雙行間距線
- 25. WPF RichtextBox中不同FontSizes的行間距
- 26. 減小TinyMCE textarea中的行間距
- 27. CSS中的行和字母間距
- 28. JTextArea行限制
- 29. 行JTextArea Java
- 30. GridBagLayout中的JTextArea竊取太多空間
嗨Surjya,你應該upvote並接受你認爲有幫助的答案:-)。你有沒有解決你的問題? – Tom 2009-12-08 06:03:42