code: protected void processPaint(Graphics gg, Shape a)
      {
          Graphics2D g = (Graphics2D) gg;
          AffineTransform tmpTransform = g.getTransform();
          if (!tmpTransform.equals(transform))
          {
              transform = tmpTransform;
              invalidateTextLayout();
          }
  
          Component c = container;
          int p0 = getStartOffset();
          int p1 = getEndOffset();
          Color fg = getForeground();
  
          if (c instanceof JTextComponent)
          {
              JTextComponent tc = (JTextComponent) c;
              if (!tc.isEnabled())
              {
                  fg = tc.getDisabledTextColor();
              }
  
              // javax.swing.plaf.basic.BasicTextUI $ BasicHighlighter
              // >> DefaultHighlighter
              // >> DefaultHighlightPainter
  
              Highlighter highLighter = tc.getHighlighter();
              if (highLighter instanceof LayeredHighlighter)
              {
                  ((LayeredHighlighter) highLighter).paintLayeredHighlights(g, p0, p1, box.getAbsoluteContentBounds(), tc, this);
                  // (g, p0, p1, a, tc, this);
              }
          }
          // nothing is selected
          if (!box.isEmpty() && !getText().isEmpty())
              renderContent(g, a, fg, p0, p1);
  
      }
docs: Process paint.
  
  @param gg
  the graphics context
  @param a
  the allocation