FULL PRODUCT VERSION :
> ../jdk1.7.0_03/bin/java -version
java version "1.7.0_03"
Java(TM) SE Runtime Environment (build 1.7.0_03-b04)
Java HotSpot(TM) 64-Bit Server VM (build 22.1-b02, mixed mode)
> ../jdk1.6.0_31/bin/java -version
java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b04)
Java HotSpot(TM) 64-Bit Server VM (build 20.6-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
openSUSE 12.1 x64
> uname -a
Linux linux64.workgroup 3.1.9-1.4-desktop #1 SMP PREEMPT Fri Jan 27 08:55:10 UTC 2012 (efb5ff4) x86_64 x86_64 x86_64 GNU/Linux
EXTRA RELEVANT SYSTEM CONFIGURATION :
Java SE6 and SE7 JDKs
A DESCRIPTION OF THE PROBLEM :
Regression in SE 7 swing TitledBorder Component for getFont() -- now returning null.
The answer to Bug 7022041 seems to imply that this is not a regression
-- that no Component getFont() can ever be depended upon!
Is this then a (default) Look & Feel regression?
REGRESSION. Last worked in version 6u29
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
see below for TtlBrder.java
> ../jdk1.6.0_31/bin/javac TtlBrdr.java
> ../jdk1.6.0_31/bin/java TtlBrdr
> ../jdk1.7.0_03/bin/java TtlBrdr
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
TitledBorder.getFont() to return a non-null Font object in SE 7,
like it did in SE 6.
ACTUAL -
With SE 6 TitledBorder.getFont() returned a non-null Font object,
but with SE 7 returns a null Font object.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
> ../jdk1.6.0_31/bin/java TtlBrdr
java.awt.Font[family=Dialog,name=Dialog,style=bold,size=12]
> ../jdk1.7.0_03/bin/java TtlBrdr
java.lang.NullPointerException
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
> cat TtlBrdr.java
import javax.swing.border.TitledBorder;
import java.awt.Font;
public class TtlBrdr {
public static void main(String[] args) {
try {
Font fnt = new TitledBorder("test").getTitleFont().deriveFont(Font.BOLD);
System.out.println(fnt);
} catch (Exception e) {
System.out.println(e.toString());
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Add a null check and getFont() from another Component (Label perhaps) for SE 7.
But bug 7022041 answer says that this can not be depended upon to work either!