user2324946
user2324946

Reputation:

Clear first line jtextarea

How do I clean or remove the first line in a JTextArea?

I have used so far

int start = 0;
                     int end = 131;
                     area.replaceRange (null, start, end);

but it is also obsolete as a method of JTextArea text is dynamic so this is not good.

Upvotes: 6

Views: 4153

Answers (1)

camickr
camickr

Reputation: 324118

Use:

int end = textArea.getLineEndOffset(0) 
textArea.replaceRange("", 0, end);

Upvotes: 16

Related Questions