--- libjava/classpath/javax/swing/text/PlainView.java~ 2007-01-09 14:58:05.000000000 -0500 +++ libjava/classpath/javax/swing/text/PlainView.java 2008-05-03 10:22:48.000000000 -0400 @@ -295,9 +295,9 @@ Rectangle clip = g.getClipBounds(); SwingUtilities.computeIntersection(rect.x, rect.y, rect.width, rect.height, clip); - int line0 = (clip.y - rect.y) / height; + int line0 = height == 0 ? 0 : (clip.y - rect.y) / height; line0 = Math.max(0, Math.min(line0, count - 1)); - int line1 = (clip.y + clip.height - rect.y) / height; + int line1 = height == 0 ? 0 : (clip.y + clip.height - rect.y) / height; line1 = Math.max(0, Math.min(line1, count - 1)); int y = rect.y + metrics.getAscent() + height * line0; for (int i = line0; i <= line1; i++) @@ -452,7 +452,8 @@ // Inside the allocation vertically. Determine line and X offset. Document doc = getDocument(); Element root = doc.getDefaultRootElement(); - int line = Math.abs(((int) y - rec.y) / metrics.getHeight()); + int met_height = metrics.getHeight(); + int line = met_height == 0 ? 0 : Math.abs(((int) y - rec.y) / met_height); if (line >= root.getElementCount()) pos = getEndOffset() - 1; else