United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-7117283 : NullpointerException when using TitleBorder.getTitleFont

Details
Type:
Bug
Submit Date:
2011-12-02
Status:
Closed
Updated Date:
2012-03-30
Project Name:
JDK
Resolved Date:
2012-03-30
Component:
client-libs
OS:
windows_7
Sub-Component:
javax.swing
CPU:
x86
Priority:
P4
Resolution:
Duplicate
Affected Versions:
7
Fixed Versions:
8

Related Reports
Duplicate:

Sub Tasks

Description
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

                                    

Comments



Hardware and Software, Engineered to Work Together