• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTextArea prob

 
john omeara
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
I have created a JTextArea which at present has scrolling abilities. The problem is that at present when the textarea fills the jtext area still displays the same text whilst giving the ability to scroll for the extra not shown. Is it possible to alter this behaviour so that the JTextArea automatically scolls so the most recent bit of text added is always viewable.
I have the following lines of code at present
text = new JTextArea("",9, 24);
text.setLineWrap(false);
text.setEditable(false);
text.setWrapStyleWord(true);
JScrollPane scrollingResult1 = new JScrollPane(text);
window.getContentPane().add(scrollingResult1, BorderLayout.NORTH);
Many thanks
John
 
Jose Botella
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have not been able to reproduce your problem because whenever I add a text to the TextArea, it gets scroll to show it. But this should work;
textA.scrollRectToVisible(textA.modelToView(textA.getDocument().getLength()));
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!