private static int getFirstLineHeight(JEditorPane text) {
    try {
      int end = text.getDocument().getLength();
      for (int i = 0; i < end; i++) {
        Rectangle2D r = text.modelToView2D(i);
        if (r != null) {
          int height = (int)r.getHeight();
          if (height > 0) return height;
        }
      }
    }
    catch (BadLocationException ignored) {
    }
    return 0;
  }
private static int getFirstLineHeight(JEditorPane text)