code: 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);
          }
      }
docs: Update the color in the default style of the document.
  
  @param color the new color to use or null to remove the color attribute
  from the document's style