Rectangle r0 = null; Rectangle r1 = null;
if (p0 == p1) return;
    public void paint(Graphics g, int p0, int p1, Shape bounds,		      JTextComponent c)    {      Rectangle r0 = null;      Rectangle r1 = null;      Rectangle rect = bounds.getBounds();            try	{	  r0 = c.modelToView(p0);	  r1 = c.modelToView(p1);	}      catch (BadLocationException e)        {	  // This should never occur.          return;	}      if (r0 == null || r1 == null)	return;      if (color == null)	g.setColor(c.getSelectionColor());      else	g.setColor(color);      // Check if only one line to highlight.      if (r0.y == r1.y)	{	  r0.width = r1.x - r0.x;	  paintHighlight(g, r0);	  return;	}      // First line, from p0 to end-of-line.      r0.width = rect.x + rect.width - r0.x;      paintHighlight(g, r0);            // FIXME: All the full lines in between, if any (assumes that all lines      // have the same height -- not a good assumption with JEditorPane/JTextPane).      r0.y += r0.height;      r0.x = rect.x;      r0.width = rect.width;      while (r0.y < r1.y)	{	  paintHighlight(g, r0);	  r0.y += r0.height;	}      // Last line, from beginning-of-line to p1.      // The "-1" is neccessary else we would paint one pixel column more      // than in the case where the selection is only on one line.       r0.width = r1.x + r1.width - 1;      paintHighlight(g, r0);    }