Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8149368

[hidpi] JLabel font is twice bigger than JTextArea font on Windows 7,HiDPI, Windows L&F

    Details

    • Subcomponent:
    • Resolved In Build:
      b114
    • CPU:
      generic
    • OS:
      windows_7

      Backports

        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.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  alexsch Alexander Scherbatiy (Inactive)
                  Reporter:
                  hschreiber Hendrik Schreiber
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: