United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-8013570 : Null pointer exception is now returned from TitledBorder::getTitleFont()

Details
Type:
Bug
Submit Date:
2013-04-04
Status:
Closed
Updated Date:
2014-11-17
Project Name:
JDK
Resolved Date:
2013-05-29
Component:
client-libs
OS:
generic
Sub-Component:
javax.swing
CPU:
Priority:
P3
Resolution:
Duplicate
Affected Versions:
7
Fixed Versions:
8

Related Reports
Duplicate:

Sub Tasks

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
                                    

Comments



Hardware and Software, Engineered to Work Together