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 2005

Tip: Looking for answers? Try searching our database.

How to set the ScrollPane to the top

Thread view: 
cybernerdsx2@yahoo.com - 18 Mar 2005 02:43 GMT
Hi,

How do I reset the JScrollPane to the topmost when I have added a very
long text into the JTextPane with JScrollPane in it?
Roland - 18 Mar 2005 07:31 GMT
> Hi,
>
> How do I reset the JScrollPane to the topmost when I have added a very
> long text into the JTextPane with JScrollPane in it?

yourJTextPane.setCaretPosition(0);

Signature

Regards,

Roland de Ruiter
  ___      ___
 /__/ w_/ /__/
/  \ /_/ /  \

Thomas Weidenfeller - 18 Mar 2005 09:01 GMT
> How do I reset the JScrollPane to the topmost when I have added a very
> long text into the JTextPane with JScrollPane in it?

setCaretPosition()

Signature

The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq

Chris Smith - 18 Mar 2005 15:55 GMT
> How do I reset the JScrollPane to the topmost when I have added a very
> long text into the JTextPane with JScrollPane in it?

If you don't want to change the caret position as others have suggested,
then try calling scrollRectToVisible on the JTextPane.  In a more
general case, if you wish to ensure that some specific character
position ("pos") is visible in a JTextComponent of any sort, then you
can say:

   JTextPane textPane = ...;
   int pos = ...;

   textPane.scrollRectToVisible(textPane.modelToView(pos));

If you use 0 for pos, this will cause the text component to scroll to
the top.

Signature

www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation



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.