JTextArea txt = new JTextArea();
StringBuffer sb = new StringBuffer();
sb.append(\"Employee Information\");
sb.append(\"\\n\");
sb.append(\"Name:\");
You can use the setFont
method. For your example try :
Font font = txt.getFont();
txt.setFont(font.deriveFont(Font.BOLD));
(Keep in mind that txt
is the JTextArea
, not your actual text.)
The JText Area is a plain text area, for styled text areas you need something like JEditorPane or JTextPane, take a look at the Documentation