how to insert or append new line on top of the jtextarea in java swing ? i want to to append jtextarea and add the new line on top of the jtextarea please help me how to do this.
You can do this:
textArea.setText("The new text\n" + textArea.getText());
Or, an even better solution would be this:
try {
textArea.getDocument().insertString(0, "The new text\n", null);
} catch (BadLocationException e) {
e.printStackTrace();
}