File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Prepend text in JTextArea Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Prepend text in JTextArea" Watch "Prepend text in JTextArea" New topic

Prepend text in JTextArea

ryan headley
Ranch Hand

Joined: Jun 28, 2000
Posts: 156
Is there a way to PREPEND text in a JTextArea rather that APPEND it?
I want the most recent addtions of text in the JTextArea to be at the top, not the bottom.
I do have JTextArea in a JScrollPane, but I would rather have ppl scroll down to see old messages and have the new onese at the top...
Any ideas?

Ryan Headley<br /><a href="" target="_blank" rel="nofollow"></a>
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Ryan,
Have a look at the insert method of JTextArea. Using position of zero should get the front.
ryan headley
Ranch Hand

Joined: Jun 28, 2000
Posts: 156
I will give that a try...
I agree. Here's the link:
subject: Prepend text in JTextArea
It's not a secret anymore!