JDK-8149368 : [hidpi] JLabel font is twice bigger than JTextArea font on Windows 7,HiDPI, Windows L&F
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 8u72
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_7
  • CPU: generic
  • Submitted: 2016-02-08
  • Updated: 2016-07-21
  • Resolved: 2016-03-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u102Fixed 9 b114Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
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.