int len = p1 - p0;
p1--; getDocument().getText(p0, p1 - p0, segment); int len = segment.toString().length();
  protected int drawUnselectedText(Graphics g, int x, int y, int p0, int p1)    throws BadLocationException  {    // FIXME: Throw BadLocationException somehow.    // Update font metrics.    updateMetrics();        // Get echo character.    char ch = getEchoChar();        // Set color for unselected text.    g.setColor(unselectedColor);    g.setColor(Color.BLACK);    // Initialize buffer for faster drawing of all characters.    int len = p1 - p0;    char[] buffer = new char[len];    for (int index = 0; index < len; ++index)      buffer[index] = ch;        // Draw echo charaters.    g.drawChars(buffer, 0, len, x, y);    // Return new x position right of all drawn characters.    return x + len * metrics.charWidth(ch);  }