Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

urgent can somebody get this scrollbar move down  RSS feed

 
sushant prabhu
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everbody
My previous post got no replies . so i am mailing my problem again.
I have a Jtextarea on which some lines are appended when a certain method is called.
The problem is as & when new lines are added the scrollbar moves up and not down so for the latest lines i have to manually pull the scroll bar down.
But in the same tJtextarea if some lines are appended via a call to a Button's actionperformed method the scrollbar automatically scrolls downwards
 
Tim Tully
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To do this, I just usually extend JEditorPane or in your case JTextArea and override setText, like this:
public class BottomJTextArea extends JTextArea
{
public void setText(String text)
{
super.setText(text);
Document d = getDocument();
select(d.getLength(), d.getLength());
}
}
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!