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

NullpointerException when using TitleBorder.getTitleFont

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "1.7.0"
      Java(TM) SE Runtime Environment (build 1.7.0-b147)
      Java HotSpot(TM) Client VM (build 21.0-b17, mixed mode, sharing)


      ADDITIONAL OS VERSION INFORMATION :
      Windows 7 sp1

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Java 7

      A DESCRIPTION OF THE PROBLEM :
      I'm migrating a swing application from Windows XP to Windows 7 and also from Java 6 to Java 7. The swing application sometimes makes the font bold to indicate that it is a mandatory value. The same piece of code works well in Windows XP and causes a NullpointerException in Windows 7.

      REGRESSION. Last worked in version 7

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run this code on Windows XP and compare result with Windows 7.

      public static void main(String[] args) {
      Font font = new TitledBorder("").getTitleFont();
      Font test = getMandatoryFont(font);
      }

      public static Font getMandatoryFont(Font font) {
      Font mandatory = font.deriveFont(Font.BOLD);
      return mandatory;
      }

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The font is changed to bold
      ACTUAL -
      In Windows XP (java7) the code works fine
      In Windows 7 (java 7) there is a NullPointerException

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      NullpointerException

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public static void main(String[] args) {
      Font font = new TitledBorder("").getTitleFont();
      Font test = getMandatoryFont(font);
      }

      public static Font getMandatoryFont(Font font) {
      Font mandatory = font.deriveFont(Font.BOLD);
      return mandatory;
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Handle null in getMandatoryFont

            rupashka Pavel Porvatov (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: