private void updateForeground ( Color color ) { StyledDocument doc = ( StyledDocument ) getComponent ( ) . getDocument ( ) ; Style style = doc . getStyle ( StyleContext . DEFAULT_STYLE ) ; if ( style == null ) { return ; } if ( color == null ) { style . removeAttribute ( StyleConstants . Foreground ) ; } else { StyleConstants . setForeground ( style , color ) ; } }
Update the color in the default style of the document .