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