List of usage examples for javax.swing JTextArea viewToModel
@Deprecated(since = "9") public int viewToModel(Point pt)
From source file:Main.java
private static List<String> getLines(JTextArea textArea) { int lineHeight = getLineHeight(textArea); List<String> list = new ArrayList<String>(); for (int num = 0;; num++) { int i = textArea.viewToModel(new Point(0, num * lineHeight)); int j = textArea.viewToModel(new Point(0, (num + 1) * lineHeight)); if (i == 0 && j == 0) { continue; }//from w ww .j ava2 s . c o m if (textArea.getDocument().getLength() == i && i == j) { break; } String s = removeTrailingNewLine(textArea.getText().substring(i, j)); list.add(s); } return list; }