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?
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.
To disable JtextField/JTextArea, call the method setEnabled() and pass the value “false” as parameter. JTextField textField = new JTextField(); textField.
The JTextArea class provides a component that displays multiple lines of text and optionally allows the user to edit the text.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With