• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

automatic scrool to the Textarea

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all!
we have a JPanel that is inside a JScrollPane.
In this panel we have different components and in particular we have a JTextArea. if we use the method setText the scrollBar move automaticly to this textArea.
Can someone explain me why this append and how can i avoid this!
thanks in advance.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you don't find another way, you could try creating the JTextArea using a custom Document model. I am not sure how complex it is to develop your own Document implementation but if this "feature" is a priority, the J2SE source code could be the place to start from...
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried to duplicate what you are describing, but I am puzzled. I don't get the scroll bars at all unless I actually type into the JTextArea. If I use setText for the JTextArea, it expands the size of the box. When I type in it, it then adds the scroll bars, but around the entire panel, not just the JTextArea.
Can you post your code?
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For the code is not easy to give because several "panel" classes are use together in the mainpanel that contains the scrollbar.

But we find a way to avoid the problem we add a scrollpane just around the text area so the scrollBar that adjust if needed is the one around the scrollpane.
it seems that the default behavour is that when you setText. The textArea try to find in the parent container the first scrollpane to focus on the added text
 
Dorothy Finkel-Laverty
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It seems that you'd want the scroll bars around the JTextArea anyhow, right? I know what you mean about it being difficult to post the code - these things get so entangled with the rest of the application that it is difficult to separate them out sometimes.
Glad you found a solution.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
exactly !
thanks to you
 
New rule: no elephants at the chess tournament. Tiny ads are still okay.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic