-
JTextArea Scrolling..?
Okay, this should be an easy one to answer, but I just can't figure it out...
I have a JTextArea that I am appending text to. I put it inside a JScrollPane so that I can get a scroll bar. The problem is that when I get enough text in the JTextArea for the scrollbar to appear, I would like the visible area of the JTextArea to display the new text that I just appended, and shift off the top line of the old text off.
Sumarizing...all I want is for the JTextArea to automatically scroll down as I add more text.
Thanks!
Code Snippet:
////////////Declarations///////////////
JTextArea statusBox = new JTextArea("Welcome!"+'\n');
JScrollPane scrollBox = new JScrollPane(statusBox);
/////////Code////////////////////
String text = "....";
statusBox.append(text + '\n');
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks