Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / March 2008

Tip: Looking for answers? Try searching our database.

Scrolling behavior on text pane

Thread view: 
Karsten Wutzke - 21 Mar 2008 22:21 GMT
Hello,

how do I achieve that a JScrollPane which has a JTextPane as viewport,
will scroll automatically along with the added text at the bottom? The
latest text entries shall be readable at all times!

TIA
Karsten
Thomas A. Russ - 21 Mar 2008 23:53 GMT
setCaretPosition to the end of the text.

 myPane.setCaretPosition(myPane.getText.length());

Signature

Thomas A. Russ,  USC/Information Sciences Institute

Karsten Wutzke - 22 Mar 2008 10:17 GMT
> setCaretPosition to the end of the text.
>
>   myPane.setCaretPosition(myPane.getText.length());
>
> --
> Thomas A. Russ,  USC/Information Sciences Institute

OK I found it. However the solution here was to use

setCaretPosition(getDocument().getLength());

instead.

setCaretPosition(getText().length()); //IllegalArgumentException (bad
position)

Don't know why though...

Karsten
Karsten Wutzke - 22 Mar 2008 10:24 GMT
> > setCaretPosition to the end of the text.
snip

> Don't know why though...

My theory is that because I'm using a styled document and the caret
likely won't care about text pane styles/contents that there's some
offsetting involved... *shrug*

Karsten


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.