-
Bug
-
Resolution: Duplicate
-
P3
-
7
-
generic
FULL PRODUCT VERSION :
java version " 1.7.0_09 "
Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
Java HotSpot(TM) Client VM (build 23.5-b02, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
In Java 7 the methods TitledBorder::getTitleFont() and TitledBorder::getTitleColor() has changed and it does not check for a null value anymore as it was done on Java 6.
In Java 6 the method was like this:
public Font getTitleFont() {
Font f = titleFont;
if (f == null)
f = UIManager.getFont( " TitledBorder.font " );
return f;
}
But in Java 7 the method is:
public Font getTitleFont() {
return titleFont;
}
Therefore if code written relying on this, it will crashed with a NullPointerException
REGRESSION. Last worked in version 7
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
A default font should be returned as it happened on Java6
ACTUAL -
Null font is returned if one does not specify a font.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
TitledBorder tb = new TitledBorder( " test " );
Font def = tb.getTitleFont();
def = def.deriveFont(Font.BOLD);
tb .setTitleFont(def);
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
You may inherit from TitledBorder and put Java6's code again.
SUPPORT :
YES
java version " 1.7.0_09 "
Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
Java HotSpot(TM) Client VM (build 23.5-b02, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
In Java 7 the methods TitledBorder::getTitleFont() and TitledBorder::getTitleColor() has changed and it does not check for a null value anymore as it was done on Java 6.
In Java 6 the method was like this:
public Font getTitleFont() {
Font f = titleFont;
if (f == null)
f = UIManager.getFont( " TitledBorder.font " );
return f;
}
But in Java 7 the method is:
public Font getTitleFont() {
return titleFont;
}
Therefore if code written relying on this, it will crashed with a NullPointerException
REGRESSION. Last worked in version 7
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
A default font should be returned as it happened on Java6
ACTUAL -
Null font is returned if one does not specify a font.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
TitledBorder tb = new TitledBorder( " test " );
Font def = tb.getTitleFont();
def = def.deriveFont(Font.BOLD);
tb .setTitleFont(def);
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
You may inherit from TitledBorder and put Java6's code again.
SUPPORT :
YES
- duplicates
-
JDK-7022041 TitleBorder Null Pointer Exception
-
- Resolved
-