if (hl != null) { Element lineEl = root.getElement(i);  if (i == count) hl.paintLayeredHighlights(g, lineEl.getStartOffset(), lineEl.getEndOffset(), s, textComponent, this); else hl.paintLayeredHighlights(g, lineEl.getStartOffset(), lineEl.getEndOffset() - 1, s, textComponent, this); }
  public void paint(Graphics g, Shape s)  {    // Ensure metrics are up-to-date.    updateMetrics();        JTextComponent textComponent = (JTextComponent) getContainer();        selectedColor = textComponent.getSelectedTextColor();    unselectedColor = textComponent.getForeground();    disabledColor = textComponent.getDisabledTextColor();    selectionStart = textComponent.getSelectionStart();    selectionEnd = textComponent.getSelectionEnd();    Rectangle rect = s.getBounds();        // FIXME: Text may be scrolled.    Document document = textComponent.getDocument();    Element root = document.getDefaultRootElement();    int y = rect.y + metrics.getAscent();    int height = metrics.getHeight();        int count = root.getElementCount();    for (int i = 0; i < count; i++)      {	drawLine(i, g, rect.x, y);        y += height;      }  }