public static int getLineCount(JTextComponent pane) { SyntaxDocument sdoc = getSyntaxDocument(pane); if (sdoc != null) { return sdoc.getLineCount(); } int count = 0; try { int p = pane.getDocument().getLength() - 1; if (p > 0) { count = getLineNumber(pane, p); } } catch (BadLocationException ex) { Logger.getLogger(ActionUtils.class.getName()).log(Level.SEVERE, null, ex); } return count; }