|
Relates :
|
|
|
Relates :
|
|
|
Relates :
|
The JTextArea font is set to half the size of the JLabel font, if viewed on Windows, with Windows Look and Feel and a HiDPI display.
Steps to reproduce:
Run the code:
================
import javax.swing.*;
import java.awt.*;
import static javax.swing.JFrame.EXIT_ON_CLOSE;
public class JTextAreaTest {
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
}
SwingUtilities.invokeLater(() -> {
final JFrame frame = new JFrame();
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
frame.setBounds(500, 500, 300, 200);
frame.setLayout(new BorderLayout());
final JLabel label = new JLabel("Regular Label");
frame.add(label, BorderLayout.NORTH);
final JTextArea textArea = new JTextArea("JTextArea Label");
frame.add(textArea, BorderLayout.CENTER);
System.out.println("Label font: " + label.getFont());
System.out.println("TextArea font: " + textArea.getFont());
frame.setVisible(true);
});
}
}
===============
Screenshots are attached.
System Output for Windows Look and Feel is:
Label font: javax.swing.plaf.FontUIResource[family=Tahoma,name=Tahoma,style=plain,size=21]
TextArea font: javax.swing.plaf.FontUIResource[family=Monospaced,name=Monospaced,style=plain,size=13]
System Output for standard Look and Feel is:
Label font: javax.swing.plaf.FontUIResource[family=Dialog,name=Dialog,style=bold,size=12]
TextArea font: javax.swing.plaf.FontUIResource[family=Dialog,name=Dialog,style=plain,size=12]
Note that the standard font sizes are too small. They don't respect the fact that we have a HiDPI display at all. However, the Windows Look and Feel font sizes for JLabel and JTextArea don't scale the same way, which is perhaps even more unfortunate.