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.

          Issue Links

            Activity

            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/client/jdk/rev/4c4c633ca2c1
            User: alexsch
            Date: 2016-03-15 16:17:10 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/client/jdk/rev/4c4c633ca2c1 User: alexsch Date: 2016-03-15 16:17:10 +0000
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/4c4c633ca2c1
            User: lana
            Date: 2016-04-13 17:56:05 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/4c4c633ca2c1 User: lana Date: 2016-04-13 17:56:05 +0000

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: