I've created an animated extension of the JLabel which imitates a "typewriter" effect. It works smoothly for single-line labels.
Here is a basic pseudo-code outline of how I went about doing it:
constructor(String fullText, int delay) {
create swing timer
start timer
}
//called by timer
actionPerformed() {
if (all chars are printed)
stop timer
else {
labelStr += fullText.charAt(pos);
this.setText(labelStr);
pos++;
}
}
The problem is, whenever It recognises an HTML line break (to make it a multi-line label), all of the text gets bumped up. Here's a
rough animation showing my animated label and a regular jlabel...
http://img223.imageshack.us/img223/8459/typewriteranizy1.gif
As you can see, once the line breaks are added to the animated label's text, all the text is moved up. This creates a choppy scrolling effect, something I'm trying to avoid at the moment.
Any ideas on how I could keep the animated text in a fixed position, so it doesn't scroll up like this?
I can provide source code if needed.