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

Inconsistent defaults for button fonts when running under Windows XP

    Details

      Description

      FULL PRODUCT VERSION :
      java version "1.4.2_02"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_02-b03)
      Java HotSpot(TM) Client VM (build 1.4.2_02-b03, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      Attempting to add a custom button as a component on a JOptionPane instance. However, when running under WIndows XP, the default font for a JButton (MS Sans Serif) is inconsistent with the default font for a button on an instance of a JOptionPane class (Tahoma).

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Basically querying for both the font of a new instance of JButton (or obtaining from the UIManager using the "Button.font" property) and comparing it with the default font stored for the JOptionPane, obtainable through the UIManager using the "OptionPane.buttonFont" property, you will find the fonts do not match.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Expecting to find the font for all buttons within Swing to be consistent with one another.
      ACTUAL -
      Font of a standard JButton does not match the font of a button in a JOptionPane.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import javax.swing.*;

      public class FontMismatchTest
      {
        public static void main(String[] args)
        {
          try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
          } catch (Exception e) {
          }

          Font buttonFont = UIManager.getFont("Button.font");
          Font optionPaneButtonFont = UIManager.getFont("OptionPane.buttonFont");
          System.out.println("Fonts match=" + buttonFont.equals(optionPaneButtonFont));
        }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Requires either at application startup to set the "Button.font" property within the UIManager to match the "OptionPane.buttonFont" property... or on a per instance basis, to change the font of a JButton to match the font of a JOptionPane button.
      ###@###.### 2005-04-05 23:01:02 GMT

        Attachments

          Activity

            People

            • Assignee:
              jmarinacsunw Joshua Marinacci (Inactive)
              Reporter:
              gmanwanisunw Girish Manwani (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: