2011-12-15 3 views
2
JTextArea txt = new JTextArea(); 
    StringBuffer sb = new StringBuffer(); 
    sb.append("Employee Information"); 
    sb.append("\n"); 
    sb.append("Name:"); 
    txt.setText(sb.toString()); 

나는 그렇게 BOLD format..How에 "직원 정보"을 설정해야합니다 .. 나는이JTextArea에서 텍스트를 스타일 화 (굵게 표시)하는 방법은 무엇입니까? 여기

sb.append("<html><b>Employee Information</b></html>"); 

같은 시도하지만 그 방법에 ... 일반적으로 텍스트를 인쇄 대담하게 만드시겠습니까?

+0

http://stackoverflow.com/questions/2713863/java-jtextarea-bold –

+0

I을 시도했습니다 .. JEditorPane textarea = new JEditorPane ("text/html", ""); textarea.setText ("여기에 일부 굵은 글씨"); sb.append ("직원 정보"); sb.append ("\ n"); sb.append ("Name :"); textArea.setText (sb.toString()); 하지만 그게 오지 않아 .. – shree

+1

고마워요. 그게 .. 일하고있어 ... – shree

답변

4

JText 지역은 당신이 JEditorPane 또는 JTextPane가 같은 뭔가가 필요 스타일 텍스트 영역에 대한 일반 텍스트 영역입니다, 당신은 setFont 방법을 사용할 수 있습니다 Documentation

3

를보십시오. 귀하의 예를 들어보십시오 :

Font font = txt.getFont(); 
txt.setFont(font.deriveFont(Font.BOLD)); 

이 (txt이 아니라 실제 된 텍스트 JTextArea 있음을 유의하십시오.)

관련 문제