code: private void updateFont(Font font) {
          StyledDocument doc = (StyledDocument)getComponent().getDocument();
          Style style = doc.getStyle(StyleContext.DEFAULT_STYLE);
  
          if (style == null) {
              return;
          }
  
          if (font == null) {
              style.removeAttribute(StyleConstants.FontFamily);
              style.removeAttribute(StyleConstants.FontSize);
              style.removeAttribute(StyleConstants.Bold);
              style.removeAttribute(StyleConstants.Italic);
          } else {
              StyleConstants.setFontFamily(style, font.getName());
              StyleConstants.setFontSize(style, font.getSize());
              StyleConstants.setBold(style, font.isBold());
              StyleConstants.setItalic(style, font.isItalic());
          }
      }
docs: Update the font in the default style of the document.
  
  @param font the new font to use or null to remove the font attribute
  from the document's style