The spec of TextAttribute states: "the default effect if the attribute is absent (or has a null value)/If the value is null or not of the proper type then it has the default effect/ BACKGROUND...Default null" However, if any of attributes have null value, constructor Font(Map) as well as method getFont(Map) throws NullPointerException. Please see sample java code attached. The result of this code run:
==================================================
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
-------------------------------------------------
java -cp ./ Test60
Key: java.awt.font.TextAttribute(background); value: null
Error: java.lang.NullPointerException
Key: java.awt.font.TextAttribute(bidi_embedding); value: null
Error: java.lang.NullPointerException
Key: java.awt.font.TextAttribute(char_replacement); value: null
Error: java.lang.NullPointerException
Key: java.awt.font.TextAttribute(family); value: null
Error: java.lang.NullPointerException
Key: java.awt.font.TextAttribute(font); value: null
Error: java.lang.NullPointerException
Key: java.awt.font.TextAttribute(foreground); value: null
Error: java.lang.NullPointerException
Key: java.awt.font.TextAttribute(input method highlight); value: null
Error: java.lang.NullPointerException
Key: java.awt.font.TextAttribute(input method underline); value: null
Error: java.lang.NullPointerException
Key: java.awt.font.TextAttribute(justification); value: null
Error: java.lang.NullPointerException
Key: java.awt.font.TextAttribute(numeric_shaping); value: null
Error: java.lang.NullPointerException
Key: java.awt.font.TextAttribute(posture); value: null
Error: java.lang.NullPointerException
Key: java.awt.font.TextAttribute(run_direction); value: null
Error: java.lang.NullPointerException
Key: java.awt.font.TextAttribute(size); value: null
Error: java.lang.NullPointerException
Key: java.awt.font.TextAttribute(strikethrough); value: null
Error: java.lang.NullPointerException
Key: java.awt.font.TextAttribute(superscript); value: null
Error: java.lang.NullPointerException
Key: java.awt.font.TextAttribute(swap_colors); value: null
Error: java.lang.NullPointerException
Key: java.awt.font.TextAttribute(transform); value: null
Error: java.lang.NullPointerException
Key: java.awt.font.TextAttribute(underline); value: null
Error: java.lang.NullPointerException
Key: java.awt.font.TextAttribute(weight); value: null
Error: java.lang.NullPointerException
Key: java.awt.font.TextAttribute(width); value: null
Error: java.lang.NullPointerException
###@###.### 10/27/04 12:05 GMT