paintHighlight(g, l1);
g.fillRect(l1.x, l1.y, l1.width, l1.height);
    public void paint(Graphics g, int p0, int p1, Shape bounds,		      JTextComponent t)    {      if (p0 == p1)          return;      Rectangle rect = bounds.getBounds();      if (color == null)        g.setColor(t.getSelectionColor());      else	g.setColor(color);      TextUI ui = t.getUI();            try	{        Rectangle l0 = ui.modelToView(t, p0, null);        Rectangle l1 = ui.modelToView(t, p1, null);                // Note: The computed locations may lie outside of the allocation        // area if the text is scrolled.                if (l0.y == l1.y)          {            SwingUtilities.computeUnion(l0.x, l0.y, l0.width, l0.height, l1);            // Paint only inside the allocation area.            SwingUtilities.computeIntersection(rect.x, rect.y, rect.width, rect.height, l1);                    paintHighlight(g, l1);          }        else          {            // 1. The line of p0 is painted from the position of p0            // to the right border.            // 2. All lines between the ones where p0 and p1 lie on            // are completely highlighted. The allocation area is used to find            // out the bounds.            // 3. The final line is painted from the left border to the            // position of p1.                        // Highlight first line until the end.            // If rect.x is non-zero the calculation will properly adjust the            // area to be painted.            l0.x -= rect.x;            l0.width = rect.width - l0.x - rect.x;                        paintHighlight(g, l0);                        int posBelow = Utilities.getPositionBelow(t, p0, l0.x);            int p1RowStart = Utilities.getRowStart(t, p1);            if (posBelow != -1                && posBelow != p0                && Utilities.getRowStart(t, posBelow)                   != p1RowStart)              {                Rectangle grow = ui.modelToView(t, posBelow);                grow.x = rect.x;                grow.width = rect.width;                                // Find further lines which have to be highlighted completely.                int nextPosBelow = posBelow;                while (nextPosBelow != -1                       && Utilities.getRowStart(t, nextPosBelow) != p1RowStart)                  {                    posBelow = nextPosBelow;                    nextPosBelow = Utilities.getPositionBelow(t, posBelow, l0.x);                                        if (nextPosBelow == posBelow)                      break;                  }                // Now posBelow is an offset on the last line which has to be painted                // completely. (newPosBelow is on the same line as p1)                                 // Retrieve the rectangle of posBelow and use its y and height                // value to calculate the final height of the multiple line                // spanning rectangle.                Rectangle end = ui.modelToView(t, posBelow);                grow.height = end.y + end.height - grow.y;                                paintHighlight(g, grow);              }                        // Paint last line from its beginning to the position of p1.            l1.width = l1.x + l1.width - rect.x;            l1.x = rect.x;            paintHighlight(g, l1);          }      }    catch (BadLocationException ex)      {        AssertionError err = new AssertionError("Unexpected bad location exception");        err.initCause(ex);        throw err;      }    }