• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

AutoScroll text to bottom of a StyledText component in SWT

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Sheriff
Posts: 22816
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JTextComponent#setCaretPosition(int positon) This is inherited by the children
 
ragz wifer
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 22816
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

ragz wifer wrote:this is not swings


Swing is a proper noun.
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic