Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JTextArea default font very small in Windows

I'm using platform look-and-fell and on Linux my JTextArea is pretty readable But on Windows it uses "Monospaced 9" and the text is very small.

Why and what is the best way to fix that?

Why default Windows look-and-fell uses such small font in JTextArea?

like image 615
Oleg Vazhnev Avatar asked Jun 23 '11 22:06

Oleg Vazhnev


People also ask

How do I change font size in JTextArea?

To set the font and color of JTextArea we can use the setFont() and setForeground() methods of the JTextArea . To create a font we must define the font name, the font style and its size. For the colors we can uses the constant color values defined by the Color class.

How do I disable JTextArea?

To disable JtextField/JTextArea, call the method setEnabled() and pass the value “false” as parameter. JTextField textField = new JTextField(); textField.

Is JTextArea editable?

The JTextArea class provides a component that displays multiple lines of text and optionally allows the user to edit the text.

What is JTextArea in Java?

A JTextArea is a multi-line area that displays plain text. It is intended to be a lightweight component that provides source compatibility with the java. awt. TextArea class where it can reasonably do so.


1 Answers

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

textArea.setFont(textArea.getFont().deriveFont(12f)); // will only change size to 12pt
like image 84
Denis Tulskiy Avatar answered Sep 21 '22 18:09

Denis Tulskiy