[ACCEPTED]-JTextArea default font very small in Windows-jtextarea

Accepted answer
Score: 29

Instead of creating new font, it is better 4 to derive existing font, because this way you'll 3 save the font set by platform look and feel, and 2 it may also avoid problems with unicode 1 characters:

textArea.setFont(textArea.getFont().deriveFont(12f)); // will only change size to 12pt
Score: 8

Here's a solution that you can use to change 6 all JTextAreas at once instead of using 5 setFont() every time you add new text 4 area:

UIManager.getDefaults().put("TextArea.font", UIManager.getFont("TextField.font"));

Call this on start of your application, after 3 setting the Look and Feel.

Most L&Fs 2 use the same font for JTextArea and JTextField, it's 1 strange that Windows doesn't.

Score: 2

If you want a consistent look then use the 5 Nimbus or Metal look and feel instead of 4 the OS default. That will also allow you 3 to tweak any settings. Plus I personally 2 I think the Nimbus Look and Feel is much 1 smoother looking than the others.

Score: 1

You can use the JTextArea1.setFont(Font(String name, int style, int size)) method to specify the specific 2 type of font for a JTextArea component. As 1 an example

jTextArea1.setFont(new Font("Arial Black", Font.BOLD, 8));

import java.awt.BorderLayout;
import java.awt.Font;
import javax.swing.JTextArea;
import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;

public class NewJFrame extends javax.swing.JFrame {

    private JTextArea jTextArea1;
    private JTextArea jTextArea2;

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                NewJFrame inst = new NewJFrame();

    public NewJFrame() {

    private void initGUI() {
        try {
                jTextArea1 = new JTextArea();
                getContentPane().add(jTextArea1, BorderLayout.NORTH);
                jTextArea1.setText("This is a fox running slow");
                jTextArea1.setFont(new Font("Arial Black", Font.BOLD, 8));
                jTextArea1.setPreferredSize(new java.awt.Dimension(164, 114));
                jTextArea2 = new JTextArea();
                getContentPane().add(jTextArea2, BorderLayout.SOUTH);
                jTextArea2.setText("This is a fox running slow");
                jTextArea2.setFont(new Font("Book Antiqua", Font.ITALIC, 12));
                jTextArea2.setPreferredSize(new java.awt.Dimension(384, 129));
            setSize(400, 300);
        } catch (Exception e) {
            //add your error handling code here

Score: 1

I've just used TextField font in TextArea...

textArea = new JTextArea();


Score: 0

Just do

textArea.setFont(new Font("Arial", Font.PLAIN, 16));

That changes all of the text inside 1 of the textarea to the same size font.

More Related questions