JDK-8013570 : Null pointer exception is now returned from TitledBorder::getTitleFont()
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • Submitted: 2013-04-04
  • Updated: 2014-11-17
  • Resolved: 2013-05-29
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8Resolved
Related Reports
Duplicate :  
Description
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