JTextPane으로 작업하고 있습니다.JTextPane 문서의 기본 속성은 어떻게 찾을 수 있습니까?
JTextPane pane = new JTextPane();
String content = "I'm a line of text that will be displayed in the JTextPane";
StyledDocument doc = pane.getStyledDocument();
SimpleAttributeSet aSet = new SimpleAttributeSet();
나는이 같은 textpane의 문서에이 aSet
을 추가하는 경우 :
doc.setParagraphAttributes(0, content.length(), aSet, false);
아무것도 볼 수 발생합니다. aSet
에 대한 맞춤 속성을 설정하지 않았으므로 놀랄 일이 아닙니다. 그러나, 나는 aSet
이 같은 doc
의 현재 ParagraphAttributes을 대체 할 수있는 경우 :
doc.setParagraphAttributes(0, content.length(), aSet, true);
많은 것들이 일어날. JTextPane 문서의 기본값에 대한 정보를 얻으려면 어떻게해야합니까? 특히 내 문제는 aSet
에 대한 사용자 지정 글꼴을 정의 할 때 현재 특성을 바꿀 것으로 설정하면 글꼴이 굵은 글꼴로 표시됩니다. StyleConstants.setBold(aSet, false);
도움이되지 않습니다.
aSet의 속성을 설정하려면 'StyleConstants.setFontFamily (aSet, "Times New Roman");'을 사용하고 완벽하게 작동합니다. :) 당신의 대답은 내가 굵은 글씨로 생각한 것은 기본'[r = 51, g = 51, b = 51]'에서'[r = 0, g = 0, b = 0]으로 리셋하는 색상 속성 (전경) ]'. 매우 감사합니다. – user2651804
@ user2651804 기꺼이 도와 드리겠습니다! 'StyleConstants.setXXX (aMutableSet, value)'메소드는 상품성을 위해 존재하며'aMutableSet.addAttribute (StyleConstants.XXX, value)'를 호출합니다. [예제] (http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/javax/swing/text/StyleConstants.java#StyleConstants.setFontFamily%28javax.swing. text.MutableAttributeSet % 2Cjava.lang.String % 29). – DSquare
우리의 삶을 편하게하기 위해 고안된 이러한 종류의 것들은 새로운 자바 프로그래머의 삶을 복잡하게 만듭니다. – user2651804