Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » How to programmatically scroll Text widget
How to programmatically scroll Text widget [message #1713505] Wed, 04 November 2015 16:52 Go to next message
Tass Burrfoot is currently offline Tass BurrfootFriend
Messages: 19
Registered: April 2015
Junior Member
Hello

I have a Text widget with scroll bar
text = new Text(contentComp, SWT.NONE | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
// layout
text.setEditable(false);


The text value is set in a background thread by calling method text.append(String). If the data to append is large, for example 1000 lines, I want to programmatically scroll down to the bottom of the current text. How can I get this working? I use RAP 2.3.2. Thanks
Re: How to programmatically scroll Text widget [message #1713512 is a reply to message #1713505] Wed, 04 November 2015 17:20 Go to previous message
Michael Fritscher is currently offline Michael FritscherFriend
Messages: 43
Registered: September 2012
Member
I've done this via a ScrolledComposite.

I'll give you some snippets - hope it helps:

	private Text wholeChatText;
	private ScrolledComposite scrollWholeChatText;

	private void scrollToTheEnd() {
		wholeChatText.append(text);
		wholeChatText.pack();
		Point p = wholeChatText.getSize();
		Point pScrollWholeChatText = scrollWholeChatText.getSize();
		wholeChatText.setSize(pScrollWholeChatText.x, p.y);
		Point pOrigin = scrollWholeChatText.getOrigin();
		System.out.println("Position: " + pOrigin);
		scrollWholeChatText.setOrigin(p.x, Integer.MAX_VALUE);
	}

	private void init() {
		scrollWholeChatText = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.BORDER);
		// SWT.BORDER | is helpfull for debug
		wholeChatText = new Text(scrollWholeChatText, SWT.READ_ONLY | SWT.WRAP | SWT.MULTI);
		scrollWholeChatText.setContent(wholeChatText);
	}

Previous Topic:How do I launch a RAP application?
Next Topic:Swing
Goto Forum:
  


Current Time: Thu Apr 25 08:16:30 GMT 2024

Powered by FUDForum. Page generated in 0.02611 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top