aspose 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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
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: 22
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: 19755
    
  20

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 - OCEEJBD 6
How To Ask Questions How To Answer Questions
ragz wifer
Greenhorn

Joined: Dec 22, 2010
Posts: 22
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: 10519
    
    9

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


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

Joined: Dec 22, 2010
Posts: 22
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: 19755
    
  20

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