Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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()));
 
Eliminate 95% of the weeds in your lawn by mowing 3 inches or higher. Then plant tiny ads:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic