Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JScrollPane Auto Scrolling for Teleprompter

882708Aug 18 2011 — edited Aug 19 2011
I am working on a piece of software to scroll text for a teleprompter. I have a class that scrolls the text that is in a JEditorPane nested in a JScrollPane. Here is the class that scrolls the text:
package teleprompter;

import javax.swing.JScrollPane;

public class Scroll extends Thread
{
    JScrollPane scrlMain;

    public Scroll(JScrollPane scrlMain)
    {
        this.scrlMain = scrlMain;
    }

    public void run()
    {
        int iPos = scrlMain.getVerticalScrollBar().getValue();

        
        for (;;)
        {
            iPos += 5;
            scrlMain.getVerticalScrollBar().setValue(iPos);
        }
    }
}
My problem is that it is not a consistent, smooth scroll so that someone can read it. It is real jumpy, sometimes it will jump an entire page. For now, the speed of the scroll can be changed by making the 5 in "iPos += 5" a higher number.

Is there a better way to do an auto scroll that is not so inconsistent and jumpy that anyone can think of?

Edited by: 879705 on Aug 18, 2011 1:40 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 16 2011
Added on Aug 18 2011
5 comments
878 views