File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes AutoScroll text to bottom of a StyledText component in SWT Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "AutoScroll text to bottom of a StyledText component in SWT" Watch "AutoScroll text to bottom of a StyledText component in SWT" New topic
Author

AutoScroll text to bottom of a StyledText component in SWT

ragz wifer
Greenhorn

Joined: Dec 22, 2010
Posts: 20
Hi,

I'm reading a text file and displaying in the styledtext component of SWT, each time a new line is appended it's not shown, i mean the line is added to the next row but the scrollbar is NOT scrolling to the next row.
How can i make it auto scroll, as a workaround i tried using it do auto scroll,but shows the complete selection which is nasty, can someone provide an optimal and better programming practice for this case.

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

In Swing you can set the caret position to the end of the document. Is that not possible in SWT as well?


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
ragz wifer
Greenhorn

Joined: Dec 22, 2010
Posts: 20
Rob Spoor wrote:In Swing you can set the caret position to the end of the document. Is that not possible in SWT as well?


how do i set caret position any example

Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 8439

JTextComponent#setCaretPosition(int positon) This is inherited by the children


[Donate a pint, save a life!] [How to ask questions] [Onff-turn it on!]
ragz wifer
Greenhorn

Joined: Dec 22, 2010
Posts: 20
Maneesh Godbole wrote:JTextComponent#setCaretPosition(int positon) This is inherited by the children


Maneesh this is not swings

anyways
i found absolute answer to my question i.e..,

my attempts 1) styledText.selectAll();//moves the autoscroll down but selects all..--not preferrable 2) styledText.setSelection(styledText.getCharacterCount());//works for me

gratitude to all for the above answers.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

ragz wifer wrote:this is not swings

Swing is a proper noun.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: AutoScroll text to bottom of a StyledText component in SWT
 
Similar Threads
swt styledtext search/find next
how to add a scrollpane...
Scroll inside styledText
Embedding components in SWT/JFace text
Eclipse Source Code