I tried to extract the last line from a JTextArea and set it to a String
this is my cod:
JTextArea text = new JTextArea();
String text2 = text.getText();
int totalLines = text.getLineCount();
for(int j=0; j < totalLines; j++) {
int end = text.getLineEndOffset(j);
String line = text2.substring(end);
}
can someoane tell me where is the mistake? thanks
Your really close, just use
JTextArea.getLineStartOffsetto get the start of the last line, example: