This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

AutoScroll text to bottom of a StyledText component in SWT

 
ragz wifer
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Swing you can set the caret position to the end of the document. Is that not possible in SWT as well?
 
ragz wifer
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JTextComponent#setCaretPosition(int positon) This is inherited by the children
 
ragz wifer
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ragz wifer wrote:this is not swings

Swing is a proper noun.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic