我做使用JTextPane
,我需要的顏色添加一些話,但我希望有一個文本編輯器,如果在已上色的區域,用戶點擊與顏色(段落樣式畫),而不是邏輯風格。我正在尋找getParagraphAttributes
,但我無法將段落樣式作爲屬性。獲取段落樣式中的JTextPane
如何獲得段落樣式在JTextPane
?
private Style getColor(String token) {
if (token.equals("while"))
return editor.getStyle("blue");
return editor.getLogicalStyle(); //At this point I want current not logical if it's Possible.
}
爲了更好地幫助越早,張貼[SSCCE(http://sscce.org/)。 – 2013-04-18 05:06:44
私人風格的getColor(字符串令牌){ 如果(token.equals( 「外衣」)) 回報editor.getStyle( 「藍」); return editor.getLogicalStyle(); //在這一點上,我希望當前不合邏輯的,如果可能的話。 } – 2013-04-18 22:12:40
我不能編輯我的問題,所以這是我能告訴你的SSCCE的唯一途徑。 – 2013-04-18 22:14:26