Re: Is it possible to create auto scroling text from bottom to top in GWT? ( not scrolling bars)

209 views
Skip to first unread message

Sridhar V

unread,
Nov 15, 2012, 10:01:12 AM11/15/12
to google-we...@googlegroups.com
any one has any clue on this?

On Wednesday, November 14, 2012 3:24:31 PM UTC-5, Sridhar V wrote:
Is it possible to create auto scroling text in GWT?  if so, please guide me how to do that.

please note that I am NOT referring to horizontal/vertical scroll bars. I am talking the text that is scrolling in a box/nugget/widget.. etc


KevMo

unread,
Nov 15, 2012, 12:54:22 PM11/15/12
to google-we...@googlegroups.com
You can always use the marquee tag. 

<marquee  behavior="scroll" direction="up">Your upward scrolling text goes here</marquee>


But please, don't have auto scrolling text. I beg you.

Sridhar V

unread,
Nov 15, 2012, 5:21:48 PM11/15/12
to google-we...@googlegroups.com
Is there any widget or panel in GWT which makes text to auto scroll?  Don't want to use marquee tag...

Milan Cvejic

unread,
Nov 17, 2012, 8:02:05 AM11/17/12
to google-we...@googlegroups.com
That one should  be easy to implement...

You could do something like this...

SimplePanel container = new SimplePanel();
container.getElement().getStyle().setOverflow(Style.Overflow.HIDDEN);

Label label = new Label("Text that you want to scroll");
label.getElement().getStyle().setPosition(Style.Position.ABSOLUTE);
container.add(label);

    private final Timer t = new Timer() {
        @Override
        public void run() {
            label.getElement().getStyle().setLeft(Integer.parseInt(label.getElement.getStyle().getLeft()) - 10, Unit.PX);
        }
    };
    t.scheduleRepeating(100);

This will move label to the left for 10px on every 100 miliseconds. So now in run() method just add math that is needed and that should be it.

PS. this might not work exactly as I typed it in, as I typed it in straight from my head without any checking, but the concept is valid.

Best,
Milan Cvejic
Reply all
Reply to author
Forward
0 new messages