• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JTextArea prob

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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()));
 
reply
    Bookmark Topic Watch Topic
  • New Topic