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

Swing font size different for Windows look and feel when using javaw

    Details

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Windows 10

      A DESCRIPTION OF THE PROBLEM :
      I have a Swing app that uses the system look and feel. When I run it with the java command, it uses one font size, but when I run it with javaw it uses a smaller font.

      REGRESSION : Last worked in version 8u202

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile the test class and run on Windows with javaw and java

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The font size should be the same with java and with javaw
      ACTUAL -
      The font sizes look different. For java, the message displayed is "Font size: 13" but for javaw it's "Font size: 11"

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;
      public class SwingTest{
      public static void main(String[]args){
      EventQueue.invokeLater(()->showFrame());
      }
      private static void showFrame(){
      try{
      UIManager.setLookAndFeel ( UIManager.getSystemLookAndFeelClassName() );
      }catch(ClassNotFoundException|InstantiationException|IllegalAccessException|UnsupportedLookAndFeelException x){
      System.err.println("Could not use system Look and Feel: "+x);
      System.exit(99);
      }
      JFrame frame=new JFrame("SwingTest");
      JLabel topLabel=new JLabel("SwingTest");
      frame.addComponentListener(
      new ComponentAdapter (){
      @Override
      public void componentShown(ComponentEvent e){
      JOptionPane.showMessageDialog(null,"Font size: "+topLabel.getFont().getSize());
      }
      }
      );
      frame.add(topLabel,BorderLayout.NORTH);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.pack();
      frame.setVisible(true);
      }
      }

      ---------- END SOURCE ----------

      FREQUENCY : always


        Attachments

          Activity

            People

            • Assignee:
              pardesha Pardeep Sharma
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: